Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Custom Class Woe 1

Status
Not open for further replies.

XofCDe3rd

Technical User
Nov 9, 2003
120
0
0
Sorry all I tried creating A custom class Lets call it TSomeClass and use it in an application...don't ask me why I did this cause I have no idea(for the fun of it???). Now It is able to compile Test.cpp but to actually make the project returns the error of this sort:

[Linker Error] Unresolved external 'TSomeClass::TSomeFunction()' referenced from C:\DOCUMENTS AND SETTINGS\DANNY\DESKTOP\TEST\TEST.OBJ

would anybody well versed at solvin this be able to help a beginner out???
 
It seems like you have made the class declaration but not the code.

A VERY simple class:
class T_TEST // Class declaration
{
private:
int Counter;
public:
void Add_One(void);
void Subtract_One(void);
int Get_Result(void);
};

The code to that class:
void T_TEST::Test(void)
{ // The constructor
Counter = 0;
}

void T_TEST::Add_One(void)
{
Counter++;
}

void T_TEST::Subtract_One(void)
{
Counter--;
}

int T_TEST::Get_Result(void)
{
return(Counter);
}

Now the declaration:
T_TEST Test; // The declaration

Now Test is a case of T_TEST and when it's declared the Constructor is executed once for each instance created.

Totte
Keep making it perfect and it will end up broken.
 
Thanks Totte got it workin.....forgot to add the unit to the project.....but you led me in the right direction anyways...

thanks for the posting I will archieve it just for referneces sake......

greatful
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top