I'm new to c++, I run the following code in visual studio c++
struct bob
{
double a,b;
bob(double a,double b);
}
int main()
{
bob z(2.2,5.6);
cout<<z.a<<endl;
keep_window_open();
return 0;
}
when I run this code, i get the following error:
Error 1 error LNK2019: unresolved external symbol "public: __thiscall bob::bob(double,double)" (??0bob@@QAE@NN@Z) referenced in function _main C:\drives\Comp-Mech\programming\V.S\C++\projects\E1\E1.obj E1
bob(double a,double b);, where is your implementation?bob(double, double) = default;and signature matches data members.classdata membersstruct X { char ch, int a; double d; };for which you use this feature and you callX x(65,32,3)somewhere else in the code. Now someone notices that you waste space and reorders the members:struct X { double d; int a; char ch; };. User code that expectedx.ch == 'A';now seesx.ch == ' '(assuming ASCII). If you provided the constructor yourself it wouldn't matter, all initialization is named