Odd question

This is a discussion on Odd question within the Windows Programming forums, part of the Platform Specific Boards category; This might sound odd, but, I was thinking about creating a class for Creating a window and putting it in ...

  1. #1
    i dont know Vicious's Avatar
    Join Date
    May 2002
    Posts
    1,200

    Odd question

    This might sound odd, but,

    I was thinking about creating a class for Creating a window and putting it in a header file.

    Now, My question is...

    Would it be a bad thing to include all the declarations and initializations all in the header file

    Code:
    //header file
    class createWindow
    {
      ...
    };
    
    createWindow::createWindow()
    {
    }
    Or should I also have a separate "cpp/c" file that links with it?

  2. #2
    S Sang-drax's Avatar
    Join Date
    May 2002
    Location
    Göteborg, Sweden
    Posts
    2,072
    If you write your header like that and include it in different source files, you'll get a linker error, so...

    Yes, you should.

    If you really want only a header file and no source file, write your header like this:
    Code:
    //header file
    namespace
    {
    
    class createWindow
    {
      ...
    };
    
    createWindow::createWindow()
    {
    }
     
    }
    Then it'll work.
    Last edited by Sang-drax : Tomorrow at 02:21 AM. Reason: Time travelling

  3. #3
    i dont know Vicious's Avatar
    Join Date
    May 2002
    Posts
    1,200
    I see..

    Thank You!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. another do while question
    By kbpsu in forum C++ Programming
    Replies: 3
    Last Post: 03-23-2009, 12:14 PM
  2. Debugging question
    By o_0 in forum C Programming
    Replies: 9
    Last Post: 10-10-2004, 05:51 PM
  3. Question...
    By TechWins in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 07-28-2003, 09:47 PM
  4. Homework help
    By Jigsaw in forum C++ Programming
    Replies: 2
    Last Post: 03-06-2002, 04:56 PM
  5. Question, question!
    By oskilian in forum A Brief History of Cprogramming.com
    Replies: 5
    Last Post: 12-24-2001, 12:47 AM

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