Error Identifier String Is Undefined
Contents |
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company c++ string undefined Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs identifier string is undefined visual studio Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, error identifier cout is undefined just like you, helping each other. Join them; it only takes a minute: Sign up identifier “string” undefined? up vote 24 down vote favorite 1 I am receiving the error: identifier "string" undefined. However, I am including
Error Identifier Getline Is Undefined
string.h and in my main file, everything is working fine. CODE: #pragma once #include
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack syntax error identifier string Overflow the company Business Learn more about hiring developers or posting ads with us Stack
String Is Undefined C++ Visual Studio
Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community
String Identifier In C
of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up Identifier [string value] is undefined [duplicate] up vote 0 down vote favorite This question already has an http://stackoverflow.com/questions/7146719/identifier-string-undefined answer here: identifier “string” undefined? 7 answers I have been making a project on C++ and I am having trouble assigning a value to a string name. I made sure to include the string library (and I did try string.h), but when I attempted to assign a value to the string name with the data type "string", it gave me the message "Error: identifier (value I assigned the string) is undefined". http://stackoverflow.com/questions/17768387/identifier-string-value-is-undefined This is kind of what the code looked like: string a = start; The word "start" was underlined in red. It was weird because when I did the same thing using an integer, it worked just fine: int a = 3; Can somebody help? Thanks c++ string undefined share|improve this question asked Jul 21 '13 at 2:01 user2602989 12 marked as duplicate by dasblinkenlight, 0x499602D2, billz, RiaD, Graviton Aug 6 '13 at 3:17 This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question. Show all the code –aaronman Jul 21 '13 at 2:02 add a comment| 2 Answers 2 active oldest votes up vote 1 down vote accepted You need to put your value into quotes: string a = "Hello World!"; But, you also need to include the right headers: #include
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About http://stackoverflow.com/questions/10589355/error-c2061-syntax-error-identifier-string Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up error C2061: syntax error : is undefined identifier 'string' up vote 2 down vote favorite this is probably an include problem, i get these errors all over the code, and not only for string identifier for example error C2146: syntax error : missing ';' before identifier 'getName' and error C2146: syntax error : missing ';' before identifier 'name' here's an example class: #include "stdafx.h" class participant { public: participant(int id, string name); ~participant(void); string is undefined int getId(); string getName(); private: int id; string name; }; here's my stdafx.h file: #pragma once #include "targetver.h" #include #include "day.h" #include "appointment.h" #include "extendedAppointment.h" #include "participant.h" #include "calendar.h" using namespace std; #define no_such_appointment_error 20; #define conflicting_appointments_error 21; #define noSuchDayError 22; #define incorrectAppointmentError 23; c++ visual-studio-2010 share|improve this question asked May 14 '12 at 18:53 Michael 6,9912171125 6 using a namespace in a header file is a terrible idea. Any file that includes your header now has using namespace std; in it (this is bad). –Ed S. May 14 '12 at 18:54 thanks, removed it. still not fixed –Michael May 14 '12 at 18:56 3 It's not directly shown to be a problem in the code you posted, since what you've posted doesn't show them being used, but macros that end in a semi-colon are nearly always going to cause problems. –Michael Burr May 14 '12 at 18:56 2 @MichaelBurr: Well if you remove that then string immediately becomes undefined (use std::string instead). Furthermore, why are your #defines ended with semi-colons? –Ed S. May 14 '12 at