• Register
1 vote
43 views

Problem:

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
{
private:
      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

Solution:

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 4 views
4 views
Problem: How to fix this error: String does a type, Someone can help me what is the meaning of this type of error
asked Apr 7 Subhendu 4.5k points
0 votes
1 answer 161 views
161 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 9.2k points
0 votes
1 answer 2 views
2 views
Problem I read similar to mine][1] [1]: Why am I getting string does not name a type Error? I couldn't find any clear answer to this anywhere.
asked Apr 9 neeraj 10.5k points
0 votes
1 answer 2 views
2 views
Problem Anyone know how i fix this type of error in c++: vector does not name a type
asked Apr 7 Subhendu 4.5k points
0 votes
1 answer 5 views
5 views
Problem: anyone who know this problem please help? class does not name a type c++
asked Mar 24 Rohit kr 16.2k points
0 votes
1 answer 23 views
23 views
problem: I just started programming in C++, and I've attempted to create 2 classes where one will contain the other. Document A.h: #ifndef _A_h  #define _A_h  class A{  public:  A(int id);  private:  int _id;  B _b;/HERE I GET A COMPILATION ERROR: B does not name a type  } ... then the A class, yet then I get the blunder message: A.h:9: error: 'B' does not name a type  How would I fix this issue?
asked Feb 17 kaash_kashi 1.2k points
0 votes
1 answer 33 views
33 views
Does c++ not name a type or it&rsquo;s incomplete type?
asked Dec 7, 2020 TeamScript 13.5k points
1 vote
1 answer 32 views
32 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 23 views
23 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 18 views
18 views
Problem: Hello I am having some problems with the methods of a class in my program, I think it is due to the distribution in different header files, I wanted to know in which particular cases this error occurs? error: request by member 'init' in ' ... "renderer/renderer.h" void init(){ Renderer mainRender(); allegro_init(); install_keyboard(); mainRender.init(); } Hope someone could help!
asked Feb 7 sasha 16.2k points