Thread: header files namesspaces in C++

  1. #1
    Registered User
    Join Date
    Jul 2008
    Location
    Sydney
    Posts
    3

    header files namesspaces in C++

    Hi guys. I am still learning C++ using Visual Studio 2005. would someone be kind enough to give me some advise?

    I am trying to basically write a GUI (for a serial camera Interface). There is a textBox. Here is my understanding of a program.
    files involved:

    mainForm.h [This is where all GUI stuff is, including declaration of textBox1]
    fileio.h
    fileio.cpp [basically in these files i declare open file close file etc.

    my question is: inside mainForm.h I have all the declaration of textBox1, menu items etc... I want to be able to access these variables from fileio.cpp file.

    for example I want to have:

    Code:
    void generateComPortList(void)
    {
    	textBox1->Text += "testing" + Environment::NewLine;
    }
    so basically I want to use write "testing" inside the textBox1 that is placed in the GUI (mainForm.h) - mostly generated by msdn2005 visual studio.

    I get the following errors:

    Code:
    1>Compiling...
    1>fileio.cpp
    1>.\fileio.cpp(78) : error C2065: 'textBox1' : undeclared identifier
    1>.\fileio.cpp(78) : error C2227: left of '->Text' must point to class/struct/union/generic type
    1>        type is ''unknown-type''
    basically I think I dont understand how variables from mainForm.h can be made accessible from fileio.cpp file.

    any help? I know I am lacking basic knowledge here about program structures. I hope someone can help me out a bit.

  2. #2
    Registered User
    Join Date
    Jul 2008
    Location
    Sydney
    Posts
    3
    I have tried writing:

    Code:
    camera::mainForm::textBox1->Text += "testing" + Environment::NewLine;
    but still i get:

    Code:
    1>Compiling...
    1>fileio.cpp
    1>.\fileio.cpp(78) : error C2227: left of '->Text' must point to class/struct/union/generic type
    compilation error

  3. #3
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    First, you must include mainForm.h inside fileio.cpp.
    If you still can't get it to work, then I must suggest that you read basics about classes and objects.
    Btw, this is C++/CLI, not C++. It is important to understand the difference.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  4. #4
    Registered User
    Join Date
    Jul 2008
    Location
    Sydney
    Posts
    3
    Quote Originally Posted by Elysia View Post
    First, you must include mainForm.h inside fileio.cpp.
    If you still can't get it to work, then I must suggest that you read basics about classes and objects.
    Btw, this is C++/CLI, not C++. It is important to understand the difference.

    i tried including mainForm.h from fileio.cpp it makes no difference.
    hhm.. I think i know the basics but still figure out why this error comes up.

    whats C++/CLI as opposed to C++?

  5. #5
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    C++/CLI is Microsoft's own version of C++ tied to the dotNet framework and have nothing to do with standard C++ that's governed by the C++ standards committee.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Checking array for string
    By Ayreon in forum C Programming
    Replies: 87
    Last Post: 03-09-2009, 03:25 PM
  2. Confusion on header and source files
    By dnguyen1022 in forum C++ Programming
    Replies: 4
    Last Post: 01-17-2009, 03:42 AM
  3. Request for comments
    By Prelude in forum A Brief History of Cprogramming.com
    Replies: 15
    Last Post: 01-02-2004, 10:33 AM
  4. more header files
    By Unregistered in forum C++ Programming
    Replies: 2
    Last Post: 10-28-2001, 01:56 PM