When I'm trying to access classes public variable (in this case trying to input text row) it shows that it's uninitialized. However, I declared it in class as a public variable. I know that's some dummy mistake, but can't find it :D
#include <iostream>
#include <conio.h>
using namespace std;
class stringlength {
private:
int lengt;
public:
char * row;
int len()
{
for (int i = 0, lengt = 0; (*(row + i) != '\0'); i++, lengt++) {}
return lengt;
}
};
int main()
{
stringlength test;
cout << "Enter a string:";
cin >> test.row;
cout << "Length is: " << test.len();
_getch();
}
This program is expected to give a length of the inputted row (like strlen function) Error is:
Error C4700 uninitialized local variable 'test' used
Thanks for help ;)