Hi, understanding the 'Visual' part of Visual C++ (MFC) becomes much more easier, if you learn the basics of object orientation first. So don't start with a GUI application but create your own small console-based projects first, add some classes and let them interact. 1. Start a new console-based project 2. Add a source-code file to that project 3. Define your main() function MyFirstProject.cpp looks like this:
#include <iostream>
using namespace std;
void main()
{
cout << "Hello World" << endl;
}
4. Create your first object (an object of the string class) MyFirstProject.cpp looks like this:
#include <iostream>
#include <string>
using namespace std;
void main()
{
string text;
text = "Hello World";
cout << text << endl;
}
5. Extract your first function MyFirstProject.cpp looks like this:
#include <iostream>
#include <string>
using namespace std;
void showMe(const string& Text)
{
cout << Text << endl;
}
void main()
{
showMe("Hello World");
}
6. Create your first class MyFirstProject.cpp looks like this:
#include <iostream>
#include <string>
using namespace std;
class MyFirstClass
{
public:
// Construction
MyFirstClass(const string& Text);
// Handling
void showMe();
private:
// Attributes
string m_text;
};
// Construction
MyFirstClass::MyFirstClass(const string& Text)
{
m_text = Text;
}
// Handling
void MyFirstClass::showMe()
{
cout << m_text << endl;
}
void main()
{
MyFirstClass MySecondObject("Hello World");
MySecondObject.showMe();
}
7. Spread your code to different files - Add a header file to your project - Add another source-code file to your project MyFirstProject.cpp looks like this:
#include "MyFirstClass.h"
void main()
{
MyFirstClass MyThirdObject("Hello World");
MyThirdObject.showMe();
}
MyFirstClass.h looks like this:
#include <string>
using namespace std;
class MyFirstClass
{
public:
// Construction
MyFirstClass(const string& Text);
// Handling
void showMe();
private:
// Attributes
string m_text;
};
MyFirstClass.cpp looks like this:
#include "MyFirstClass.h"
#include <iostream>
// Construction
MyFirstClass::MyFirstClass(const string& Text)
{
m_text = Text;
}
// Han