You need to have
#include <string>
in the header file too.The forward declaration on it’s own doesn’t do enough.
Also strongly consider header guards for your header files to avoid possible future problems as your project grows. So at the top do something like:
#ifndef THE_FILE_NAME_H #define THE_FILE_NAME_H /* header goes in here */ #endif
This will prevent the header file from being #included multiple times, if you don’t have such a guard then you can have issues with multiple declarations.
Related Posts:
- Error “C++ requires a type specifier for all declarations whilst defining methods”
- Expression must have class type
- How do I include the string header?
- c++ “Incomplete type not allowed” error accessing class reference information (Circular dependency with forward declaration)
- Why is enum class preferred over plain enum?
- Why am I getting this redefinition of class error?
- Single class has a Class Redefinition Error
- C++ Linked List Node with class
- (->) arrow operator and (.) dot operator , class pointer
- Separating class code into a header and cpp file
- how to define -std=c++11 as default in g++
- Pointer to incomplete class type is not allowed
- Why am I getting this redefinition of class error?
- push_back vs emplace_back
- no default constructor exists for class
- C++ Fatal Error LNK1120: 1 unresolved externals
- Visual Studio debugger error: Unable to start program Specified file cannot be found
- Getting error “a nonstatic member reference must be relative to a specific object” while both member are in the same class
- What are the differences between struct and class in C++?
- error C2011: ” : ‘class’ type redefinition
- push_back vs emplace_back
- General way of solving Error: Stack around the variable ‘x’ was corrupted
- The compiler is complaining about my default parameters?
- Already defined in .obj – no double inclusions
- C++ Linked List Node with class
- Getting error: ISO C++ forbids declaration of with no type
- IntelliSense: the object has type qualifiers that are not compatible with the member function
- “used without template parameters”
- Error “system” is ambiguous?
- expected constructor, destructor, or type conversion before ‘(’ token
- C++ Class ‘undeclared identifier”
- c++ “Incomplete type not allowed” error accessing class reference information (Circular dependency with forward declaration)
- Base class undefined
- Warning: non-static data member initializers only available with -std=c++11 or -std=gnu++11?
- What is the meaning of a C++ Wrapper Class?
- Does C++11 have C#-style properties?
- G++ undefined reference to class::function
- Creating an instance of class
- Error “Unterminated conditional directive” in cross-referencing headers
- expected primary-expression before ‘]’ token
- What is the return type of sizeof operator?
- error C2065: ‘cout’ : undeclared identifier
- How to install Visual Studio Build Tools 2010 on Visual Studio 2015 Community?
- istream and ostream problem – C++
- Struct with template variables in C++
- error: no member function declared in class
- Here is some error with my .h file which show [Error] unterminated #ifndef when I include my class template in it
- Error: invalid use of member in static member function
- Is “delete this” allowed in C++?
- How to create a dynamic array of integers
- How do I build a graphical user interface in C++? [closed]
- How to dynamically allocate arrays in C++
- What does (~0L) mean?
- How to throw a C++ exception
- How to fix C++ error: expected unqualified-id
- How to track down a “double free or corruption” error
- Error: “expression must have integral or unscoped enum type” [duplicate]
- How to fix C++ error: expected unqualified-id
- Reading from file in c++ ifstream
- How do I iterate over the words of a string?
- C++ IDE for Macs
- C++ Error: No match for ‘operator=’
- How to fix ‘No match for operator[]’ error (c++)
- std::cin.getline( ) vs. std::cin
- Vector is not a Template?
- Displaying a vector of strings in C++
- ‘vector’ in namespace ‘std’ does not have a template type
- Floating Point Exception C++ Why and what is it?
- Issue with std::stol – ‘std::invalid_argument’ what(): stol
- Writing a LinkedList destructor?
- Is there ‘byte’ data type in C++?
- How to return a string from a C++ function?
- C++, random number w/ range of 1-6
- What does “missing template argument” mean?
- How do conversion operators work in C++?
- What is the difference between isdigit() and isnumber()?
- Convert char* to string C++
- C++ delete vector, objects, free memory
- Copy a file in a sane, safe and efficient way
- c++ convert string to hex
- LINK : fatal error LNK1561: entry point must be defined ERROR IN VC++
- Multiple OR or AND conditions in IF statement
- What does it mean double free detected in tcache 2 while using mpz?
- What is the C equivalent to the C++ cin statement?
- c++ Read from .csv file
- Check if C++ Array is Null
- Random not declared in scope
- Destructor for a doubly-linked list that points to its value
- cin.ignore(numeric_limits
::max(), ‘\n’) - LLVM Compiler 2.0: Warning with “using namespace std;”
- ERROR: Control may reach end of non-void function /
- Function stoi not declared
- What’s the difference between while(cin) and while(cin >> num)
- Too many arguments to function
- not declared in this scope’ when using strlen()
- Converting a Cubemap into Equirectangular Panorama
- Why is this vector iterator not incrementable?
- glibc detected : double free or corruption
- How to implement Java “Scanner” in C++?
- Get Current Time in mm/dd/yyyy in C++