In which situation do i have to use classes? And data structures? I'm a beginner, and i really don't see the difference between them. I mean the output is the same.
#include "stdafx.h"
#include <iostream>
usingnamespace std;
struct first
{
int one;
int two;
} number1;
class second
{
public:
int three;
int four;
};
int main()
{
number1.one=1;
number1.two=2;
second number2;
number2.three=3;
number2.four=4;
cout << number1.one << "\n";
cout << number1.two << "\n";
cout << number2.three << "\n";
cout <<number2.four << "\n";
return 0;
}
And an other problem:
It doesn't work with strings. If i set a string value for example for two (in the struct) or for four (in the class), i can't write the value. I know how i set it to a string (for example: string two;), but it doesn't work.