trouble grasping constructing and overall use of class

having trouble with the concepts of writing constructors and objects.

here is my code, very basic but there are red lines beneath the word after the ::

if anyone could help, it'd be greatly appreciated. I read the books, copied their format, but it doesnt work for me.


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
// newproject2.cpp : Defines the entry point for the console application.
//

#include <iostream>
#include <fstream>
#include <string>
#include <math.h>

using namespace std;

class newUser{
public:
	newUser();
	string name;
	string password;
	
};

newUser::newUser{
	cout<<"Welcome to the New User Menu!:"<<endl;
};

string newUser::name{
	cout<<"please enter new user name:"<<endl;
	cin>>name;
};

string newUser::password{
	cout<<"Please enter password:"<<endl;
	cin>>password;
};
name and passwords are member variables and not functions so you can't give them code like that.
what would be good way to code it? i'm trying to have a menu to create a username and password. i just don't really understand it....
even when i user the constructor newuUser::newUser it doesnt work and thats how the manual said to create a constructor.
line 19 newUser::newUser(){
it says declaration is incompatible and looks like a function but has no parameters
i got it, turns out the() was needed. thanks!
Topic archived. No new replies allowed.