I've created a separate class file and wrote a very simple cout function to print something to the screen, this was only to see if i could make it work.
https://www.youtube.com/watch?v=NTip15BHVZc
This was the video i was trying to follow and have a few differences from the code used in the video which i assume is because im using Visual Studio instead of Codeblocks.
One difference is, when i created the class, i was presented with two prototypes in the header file instead of just the one i expected.
This is what my header file looks like :
1 2 3 4 5 6 7
|
1 #pragma once
2 class Myclass
3 {
4 public:
5 Myclass();
6 ~Myclass();
7 };
|
I don't know what the difference is between the two or what to do with the second one, if someone could clarify that would be great.
Also ill provide all my code because i don't know what people will need and what they won't, thanks for the help.
My main .cpp
1 2 3 4 5 6 7 8 9 10
|
#include "stdafx.h"
#include <iostream>
using namespace std;
int main()
{
Myclass Object;
return 0;
}
|
My header file.
1 2 3 4 5 6 7 8 9
|
#pragma once
class Myclass
{
public:
Myclass();
~Myclass();
};
|
And lastly my class .cpp
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
|
#include "stdafx.h"
#include "Myclass.h"
#include <iostream>
using namespace std;
Myclass::Myclass()
{
cout << "Test for seperate class file" << endl;
}
Myclass::~Myclass()
{
}
|
If any more information is needed, i will reply. Thanks again.
Edit: My main question is, how do I get my program to actually work, and what is the cause of the error "Myclass undeclared identifier?"