I'm having a really hard time understanding classes.
As the subject reads, i'm having a huge amount of trouble understanding classes. The tutorials on this sight are good, but they don't give enough simple examples for me to follow on. What I'm having trouble with is calling a function that belongs to the class in main().
The following program isnt sopposed to do anything at all, its just used to understand how classes work.
Code:
#include <iostream>
#include <stdlib.h>
#include <fstream.h>
class aclass
{
public:
aclass(int num1, int num2);
~aclass();
int aclass::afunction();
};
aclass::aclass(int num1, int num2)
{
num1, num2 = 2;
cout<<num1*num2;
}
aclass::~aclass()
{}
int aclass::afunction()
{
cout<<"do this stuff";
}
int main(int argc, char *argv[])
{
aclass theclass;
theclass.afunction();
system("PAUSE");
return 0;
}
The code doesnt compile if I call afunction() inside main. Help needed. Thankyou to all in advance.
Also, can someone direct me to more class (or full C++) tutorials I can find on the web. Using more then one source helps me learn better, and im having trouble finding another at the moment.