New to the language, need help with program.

Hello everyone! I am, as the title says, fairly new to c++. I am trying some very basic commands, and I figured I would try and make a cout statement in OOP format. here is my code:

#include "stdafx.h"
#include <iostream>
#include <string>

using namespace std;

class myClass
{
public:
myClass();
~myClass();
void print();
};

void print()
{
cout<< "Hello World!"<<endl;
}


int main()
{
myClass class1;
class1.print;

system("pause");
return 0;
}

: now my question is, what is wrong with it? My compiler will tell me like 6 different things when I try to resolve this, so I figure I would ask a real person before assuming that my computer is just making things up.
When you define the content of your print() function, you have to indicate that's the print() function of your myClass class you're defining, because your compiler can't guess it.
Try replacing void print() with void myClass::print().
Topic archived. No new replies allowed.