• Register
1 vote


I wrote a simple program in c++ and it throws back an error: “string does not name a type

Find my program snippet below:

#include <iostream>
#include <fstream>
#include <string>

using namespace std;
class MyClass
      string description; 
      int test;              

Could you please pull me up?

12 7 7
15,250 points

Please log in or register to answer this question.

1 Answer

0 votes


You can’t define a string like that. Change the "string" to "std::string

13 9 6
94,240 points

Related questions

0 votes
1 answer 19 views
Does c++ not name a type or it&rsquo;s incomplete type?
asked Dec 7, 2020 TeamScript 10.3k points
1 vote
1 answer 14 views
Problem: Hello guys, I am a novice in the programming world. I&rsquo;ve started learning with the C/C++ language. I&rsquo;ve got a piece of C++ code with two classes. The program is throwing a compile-time error does not name a type I am ... receiveMessage(); vector<Message> *dataMessageList; }; I am looking forward to having a legitimate solution to the problem. Thanks for your kind concern
asked Apr 29, 2020 Gavin 15.3k points
0 votes
1 answer 81 views
Problem: I have been working on classes in C++ for about a few days. I am learning constructors with parameters. I was trying to run the following program in which I have declared two constructors, one without parameters and other with one parameter. The problem ... The program works perfectly when I comment out the error-generating statement. I have no idea what I am doing wrong. Please Help.
asked Nov 9, 2020 Code Learner 5.5k points
0 votes
1 answer 22 views
I have created a Person class with two attributes, age and name, and later I have implemented a vector of people to try to print the attributes of the objects entered there. When I try to access the age attribute, there is no problem and it prints the values to me, but when trying to access ... people_vector.begin ();   while (it! = vector_people.end ())   {     it-> getName ();     it ++;   } }
asked Aug 15, 2020 game 4.6k points
0 votes
1 answer 35 views
Problem: I am making a program which consists of solving a 2x2 equation, for this I used the Cramer method, the problem is not how to solve it, but it throws an error when executing it, and I suspect that it is because I used methods of the Matrix class Inside the Vector class ... " using namespace std; int main () { cout << "As long as the program compiles well it is enough" << endl; return 0; }
asked Nov 5, 2020 sasha 5.3k points
0 votes
1 answer 20 views
Problem: Errors: ||=== terrac, Debug ===| C:\terrac\gameObject.cpp|4|error: redefinition of `class gameObject'| C:\terrac\gameObject.h|3|error: previous definition of `class gameObject'| ||=== Build finished: 2 errors, 0 warnings ===| I can't figure out what's wrong. Help?
asked Dec 27, 2020 Mashhoodch 6.1k points
0 votes
1 answer 2 views
Problem Hey, I just want to know what are nested classes?
asked Dec 19, 2020 chris jordan 2.2k points
0 votes
1 answer 16 views
Problem Hey, I need to submit an assignment on the parking ticket simulator system. Please help me by providing me the best one that you can create for me.
asked Dec 2, 2020 chris jordan 2.2k points
0 votes
1 answer 10 views
Problem: Hi there! I have a class named vehicle and now I want to make objects of this class and instantiate them with some value. How can I instantiate an object of a custom class in C++?
asked Oct 13, 2020 Code Learner 5.5k points
1 vote
1 answer 818 views
Problem : Currently I have newly joined a DLL project I am trying to write the class which has variables and functions in its header and the required definitions in the .cpp file. In my constructor I really have no problems but in my getMyPoint() function I often face below ... symbol errors in a same place, in the getMyPoint(). I am looking for C++ expert who can help me in fixing above error.
asked Apr 27, 2020 stewart 4k points