rmc/rmc.h:18: error: ISO C++ forbids declaration of `rules' with no type
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Thread: rmc/rmc.h:18: error: ISO C++ forbids declaration of `rules' with no type

  1. #1
    Join Date
    Aug 2010
    Posts
    6

    rmc/rmc.h:18: error: ISO C++ forbids declaration of `rules' with no type

    Code:
    #ifndef _RMC_H
    #define	_RMC_H
    
    
    #include <cstdio>
    #include <string>
    #include <vector>
    
    class RMC {
        std::vector <std::string> rules;
        rules.push_back("This is a string");
    
    };
    
    
    
    #endif	/* _RMC_H */
    I have worked on this for a while. It works when I put it in the main() function, but never in classes. Why? Any help sure is appreciated!

  2. #2
    Join Date
    Jan 2006
    Location
    Singapore
    Posts
    6,261

    Re: rmc/rmc.h:18: error: ISO C++ forbids declaration of `rules' with no type

    This statement should be placed in a function:
    Code:
    rules.push_back("This is a string");
    It does not belong in a class definition (unless it is within a function) because it is not some declaration of a member variable, member function, etc.
    C + C++ Compiler: MinGW port of GCC
    Build + Version Control System: SCons + Bazaar

    Look up a C/C++ Reference and learn How To Ask Questions The Smart Way
    Kindly rate my posts if you found them useful

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Azure Activities Information Page

Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center