Having problem with storage class

Im having the error of the storage class. pls help me

register.cpp
#include <iostream>
#include "Register.h"
#include <string>


using namespace std;

int main(){
string name, ic , address , model , colour;
float engineCapacity;

cout << "Please enter the detail of the ownership : ";
cout << endl <<"Please enter name your name : ";
cin >> name;
cout << endl << "Please enter your IC : ";
cin >> ic;
cout << endl << "Please enter your address : ";
cin >> address;
cout << endl;
cout << endl;


cout << "Please enter the detail of the vehicle : ";
cout << endl <<"Please enter the vehicle's model name' : ";
cin >> model;
cout << endl << "Please enter your colour of the vehicle : ";
cin >> colour;
cout << endl << "Please enter your engine capacity of the vehicle : ";
cin >> engineCapacity;
cout << endl;


register r1(string name,string ic,string address,string model,string colour,float engineCapacity); //this is the error im occuring right now. [Error] expected id-expression before 'register'

return 0;
}


Register.h
#include<iostream>
#include<string>

using namespace std;

#ifndef REGISTER_H
#define REGISTER_H

class Register

{
private:
string name,ic,address,model,colour;
float engineCapacity;

public:
Register(string, string,string,string,string, float); //Constructor
string getName();
string getIc();
string getAddress();
string getModel();
string getColour();
float getEngineCapacity();
};

#endif


Register1.cpp
#include "Register.h"
#include <iostream>
#include <string>

using namespace std;

Register::Register(string name, string ic, string address, string model, string colour, float engineCapacity){
this->name = name;
this->ic = ic;
this->address = address;
this->model = model;
this->colour = colour;
this->engineCapacity = engineCapacity;
}

string Register::getName(){
return name;
}
string Register::getIc(){
return ic;
}
string Register::getAddress(){
return address;
}

string Register::getModel(){
return model;
}
string Register::getColour(){
return colour;
}

float Register::getEngineCapacity(){
return engineCapacity;
}

Last edited on
the error is at the register.cpp on register r1 ()
register is a language keyword. It has (had) a special meaning; you may not use it as an identifier.
Last edited on
register is a keyword.
https://en.cppreference.com/w/cpp/keyword/register
You need to pick another name.


And use the code tags when you post code.
https://www.cplusplus.com/articles/jEywvCM9/
Your class name is capitalized (as is well and good).
So it should be:

 
Register r1(...);

thx for the help guys but right now im ahving the 2nd problem when trying to run the code. The error is [Error] prototype for 'Register::Register(std::string, std::string, std::string, std::string, std::string, float, std::string)' does not match any in class 'Register1'. the error is on Register1.cpp

'Register::Register(std::string, std::string, std::string, std::string, std::string, float, std::string)' does not match any in class 'Register1'.


The error message tells you what is wrong. You don't have that constructor in your Register1 class. Check your constructor definitions to see if you have that exact constructor with all the parameters.
Last edited on
ty i manage to solve the problems.
Topic archived. No new replies allowed.