Thread: C++ Classes, includes and so forth

  1. #1
    Registered User
    Join Date
    Feb 2013
    Posts
    6

    C++ Classes, includes and so forth

    Hello,

    I'm doing a very simple content managment system. We have a database of 3 tables; booze, cars and houses. User can add tuple (x, y) to respective table, where x is type and y is amount.

    Reason for this trivial software is to learn a second language aside Java.

    Simple monolithic programs (1 file main.cpp) from course are straightforward, but in example I present (see attachment) classes are not recognized in other files.

    Can someone please take a look? It's very fustrating to receive error's when I'm not sure of the cause.

    Thanks,
    zoom
    Attached Files Attached Files

  2. #2
    Registered User
    Join Date
    Jul 2010
    Posts
    27
    In CMS.h, you should add

    Code:
    #include "Table.h"
    right before the class definition, so the compiler can find the 'Table' class.

    Also in 'Table.h' add:

    Code:
    #include <multimap>
    and change

    Code:
    multimap<uint32_t, uint32_t> items;
    to

    Code:
    std::multimap<uint32_t, uint32_t> items;
    Finally in 'Table.cpp' you write:

    Code:
    #include <iostream>
    #include <map>
    #include <stdint.h>
    #include <unistd.h>
    using namespace std;
    #include "Table.h"
    You should generally avoid the 'using namespace xxx' commands, but if you want to use it, put it after all #include's.

  3. #3
    Registered User
    Join Date
    Feb 2013
    Posts
    6
    Wow many thanks! I was able to fix everything with your help.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. who includes who?
    By sept in forum C++ Programming
    Replies: 5
    Last Post: 02-23-2008, 06:53 AM
  2. Different includes
    By Ganoosh in forum C++ Programming
    Replies: 10
    Last Post: 06-22-2005, 01:52 PM
  3. ANSI/ISO includes
    By HybridM in forum C++ Programming
    Replies: 2
    Last Post: 02-01-2003, 05:51 AM
  4. Includes
    By golfinguy4 in forum Windows Programming
    Replies: 7
    Last Post: 01-29-2002, 05:29 PM
  5. #includes
    By RedLenses in forum C++ Programming
    Replies: 3
    Last Post: 01-02-2002, 03:59 PM