I'm beginner in c++, I'm trying to run this simple code using __declspec inside a class for get & put properties but the VScode does not recognize the get&put properties within __declspec as shown in the picture[enter image description here] :https://i.stack.imgur.com/iqxzi.jpg
the full message of the error(above in the picture)
// This is the source code
#include <iostream>
using namespace std;
class clsPerson
{
private:
string _FirstName;
public:
void SetFirstName(string FirstName)
{
_FirstName = FirstName;
}
string GetFirstName()
{
return _FirstName;
}
__declspec(property(get = GetFirstName, put = SetFirstName)) string FirstName;
};
int main()
{
system("cls");
clsPerson Person1;
Person1.SetFirstName("Zak");
cout << Person1.GetFirstName() << endl;
// instead of the above we only write this
Person1.FirstName = "Zak";
cout << Person1.FirstName;
system("pause>0");
return 0;
};
I tried to include all possible libraries but with no result..
Thanks in advance for all help and support :-)
__declspec
is for, you are not using it.__
in code you need to stop and make certain its for your tools and not some other tools._FirstName
also breaks the the rules.