Error using string class type

This is a discussion on Error using string class type within the C++ Programming forums, part of the General Programming Boards category; My code is simple. This file is being added to a MSVC++ 6.0 program once I get past this error. ...

  1. #1
    Registered User
    Join Date
    Jan 2005
    Posts
    20

    Error using string class type

    My code is simple. This file is being added to a MSVC++ 6.0 program once I get past this error. Below you'll see the header and source file.

    Code:
    #ifndef READCONFIGFILEH
    #define READCONFIGFILEH
    #include <string>
    
    void ReadConfig(int Values[], unsigned int *SizeValues);
    
    #endif
    Code:
    //	This is ReadConfigFile.cpp
    
    #include <cstdlib>
    #include <string>
    #include <iostream>
    #include "ReadConfigFile.h"
    
    void ReadConfig(int Values[], unsigned int *SizeValues)
    {
    	string infile("C:\\TrackerConfig.txt");
    }
    My error is:
    ReadConfigFile.cpp(9): error: identifier "string" is undefined

    which means it doesn't know variable infile

    I have #included <string> header file so I do not know what is going wrong. I already tried #included <string.h>, which didn't help. Any advice is greatly appreciated!

  2. #2
    ZuK
    ZuK is offline
    Registered User
    Join Date
    Aug 2005
    Location
    Austria
    Posts
    1,990
    Code:
    void ReadConfig(int Values[], unsigned int *SizeValues)
    {
    	std::string infile("C:\\TrackerConfig.txt");
    }

  3. #3
    Registered User
    Join Date
    Aug 2002
    Location
    Hermosa Beach, CA
    Posts
    446
    Or:

    Code:
    #include <string>
    using namespace std;
    The crows maintain that a single crow could destroy the heavens. Doubtless this is so. But it proves nothing against the heavens, for the heavens signify simply: the impossibility of crows.

  4. #4
    Registered User hk_mp5kpdw's Avatar
    Join Date
    Jan 2002
    Location
    Northern Virginia/Washington DC Metropolitan Area
    Posts
    3,801
    Or:

    Code:
    #include <string>
    using std::string;
    "Owners of dogs will have noticed that, if you provide them with food and water and shelter and affection, they will think you are god. Whereas owners of cats are compelled to realize that, if you provide them with food and water and shelter and affection, they draw the conclusion that they are gods."
    -Christopher Hitchens

  5. #5
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,893
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 4
    Last Post: 03-03-2006, 01:11 AM
  2. Please Help - Problem with Compilers
    By toonlover in forum C++ Programming
    Replies: 5
    Last Post: 07-23-2005, 10:03 AM
  3. Classes inheretance problem...
    By NANO in forum C++ Programming
    Replies: 12
    Last Post: 12-09-2002, 02:23 PM
  4. gcc problem
    By bjdea1 in forum Linux Programming
    Replies: 13
    Last Post: 04-29-2002, 06:51 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21