G
greg
Hi All,
Could anyone tell me when one should use objects and when pointers?
Thanks,
Greg
Could anyone tell me when one should use objects and when pointers?
Thanks,
Greg
greg said:Could anyone tell me when one should use objects and when pointers?
Hi All,
Could anyone tell me when one should use objects and when pointers?
So I have had an application that I have been using for over 5 years
developed under Gnu C++ 2.96 on fedora core 2. I recently updated to
fedora core 6 and now this same application is breaking.
Here is the typical message:
/home/joec/develop/c_source/SMARTrain_cmd/main.cpp:139: undefined
reference to `TSettings::TSettings()'
/home/joec/develop/c_source/SMARTrain_cmd/main.cpp:140: undefined
reference to `TRider::TRider()'
/home/joec/develop/c_source/SMARTrain_cmd/main.cpp:146: undefined
reference to `TBike::init_bike(TBike**)'
/home/joec/develop/c_source/SMARTrain_cmd/main.cpp:147: undefined
reference to `TDaily::init_date(TDaily**)'
/home/joec/develop/c_source/SMARTrain_cmd/main.cpp:148: undefined
reference to `TMaint::init_maint(TMaint**)'
Here is a simple class declaration:
/*-------------------------------------------------------------------*/
class TSettings {
private:
public:
char vstr[2];
char date_fmt[2];
char dist_fmt[2];
char alm_set[2];
char hrm_set[2];
char upd_on[2];
char fil_sve[2];
TSettings();
void Display_settings();
TSettings* System_set(TSettings *uset, bool file);
TSettings* Edit_settings(TSettings *uset, char fmt[4]);
};
/*----------------------------------------------------------------------------------*/
class TBike {
private:
public:
char Type[2 * BYTE]; // This is the keyword entry for this
linked list.
char Bike[2 * BYTE];
char Wheels[4 * BYTE];
char Grouppo[3 * BYTE];
bool track;
TBike* nxt_Bike;
TBike* init_bike(TBike **pBike);
TBike* bike_profile(TBike **pBike);
void print_bike(TBike *pBike);
int cnt_bike_list(TBike *pBike);};
/*----------------------------------------------------------------------------------*/
Here are where the above classes are first declared in main.cpp:
TSettings uset;
TRider rider;
I heard that changes were made for the new(er) version of g++ (FC6 uses
gcc version 4.1.1), but I didnt think that it would break my code as it
has.
I guess my question was: how do we know when to allocate stuff on the
heap and when on the stack?
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.