The object of Your Affection - Stuck

Hi all, i got very stuck on the object of your affection project. This is what i have so far.

</
Under app.cpp:
#include

#include “profile.hpp”

int main() {

Profile sam (“Sam Drakkila”, 30, “New York”, “USA”, “he/him”);
std::cout << sam.view_profile();

}

/>
</
under profile.hpp

#include

class Profile{
private:
std::string name;
int age;
std::string city;
std::string country;
std::string pronouns;
std::vectorstd::string hobbies;
public:

Profile(std::string new_name, int new_age, std::string new_city, std::string new_country, std::string new_pronouns = “they/them”) ;

std::string view_profile(){

}
};

/>

And profile.cpp:
#include
#include “profile.hpp”

Profile::Profile(std::string new_name, int new_age, std::string new_city, std::string new_country, std::string new_pronouns)
: name(new_name), age(new_age), city(new_city), country(new_country), pronouns(new_pronouns) {

not sure what i have missing to move forward. Im around the step 6/7

2 Likes

Any luck? I am stuck on Step 6. I am getting an error after compiling.

Remove the default string assignment on pronouns in the default constructor, i.e. in profile.hpp, change:

Profile(std::string new_name, int new_age, std::string new_city, std::string new_country, std::string new_pronouns = "they/them");

to:
Profile(std::string new_name, int new_age, std::string new_city, std::string new_country, std::string new_pronouns);

NB: This is a stop-gap measure, but should allow you to progress past step 6 for the time being. Good luck.

Hello @cloudsurfer18009,

I am on the same situation. It does not complies. It said me an error in class Profile but I do not understand why, because the class Profile are declared correclty in .hpp file … so any idea what you thing it is?

This is the compiler menssage:

profile.cpp:4:1: error: ‘Profile’ does not name a type; did you mean tmpfile’?
Profile::Profile(string new_name, int new_age, string new_city, string new_country, string new_pronouns): name(new_name), age(new_age), city(new_city), country(new_country), pronoun(new_pronouns){```

It says that Profile should be “tmpfile”… what is mean “tmpfile”?

Thank you!

Regards!

Hello, @jaguirreluna.

It would be helpful if you post your code, but I suspect that you may have forgotten to include the Profile.hpp file in your Profile.cpp file:

#include "Profile.hpp"
1 Like

Hello, @midlindner ,

thanks for answer! :grinning_face_with_smiling_eyes:
it has already wrotte in the header :confused: but let me show you the code;

// app.cpp
#include
#include “profile.hpp”

int main() {

Profile sam(“Sam Drakkila”, 30, “New York”,“USA”, “he/him”);

}

// profile.hpp
#include
using namespace std;

class Profile{

private:
string name;
int age;
string city;
string country;
string pronouns;
vector hobbies;

public:
Profile(string new_name, int new_age, string new_city, string new_country, string new_pronouns);

};

// profile.cpp

#include
using namespace std;

Profile::Profile(string new_name, int new_age, string new_city, string new_country, string new_pronouns)
: name(new_name), age(new_age), city(new_city), country(new_country), pronoun(new_pronouns){
}

Sorry I wont show the code but I was necessary haha…

As you mentioned I has already add profile.hpp in the main sequence. The compiler said Profile not name a type … but when in profile.cpp I call Profile::Profile looks it does not find it in profile.hpp… or in app.cpp sam is not named as a Profile?.. if you explain me what is happen or what are try to say the compiler we can get the solutions toggether.

Thank you for you help!

1 Like

Make sure you click Run after making any changes to your code before compiling. Run actually just saves your code. If you don’t click it, the previously saved code is re-compiled instead of your new code.

… for sure I already know it, all changes that I do I press blessing buttom. But my question was:

  1. why Profile is not named as a type?

thanks!

you need to include profile.hpp in profile.cpp
also im not sure why you have blank #include with no library. Get rid of those.

1 Like

Hi @fight_dragons ,

thank you! it are really complie, :smile: the “include profile.hpp” in profile.cpp were missing. :sweat_smile:

and about blank in #include it is because "<> symbols " did not appear in moment I wrote.

Thank you! :star_struck: