C++ Noob Class Confusion

This is a discussion on C++ Noob Class Confusion within the C++ Programming forums, part of the General Programming Boards category; Originally Posted by Freestyler Why do you believe my "QString File;" is not having any global affect? And what is ...

  1. #16
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,185
    Quote Originally Posted by Freestyler View Post
    Why do you believe my "QString File;" is not having any global affect? And what is the standard method to share the "File" data in this case between classes?
    Because I can read. You explicitly state, by saying "QString File;" that you discard all possibility of using the global variable of the same name. It no longer exists for you to use.

  2. #17
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,413
    Quote Originally Posted by Freestyler View Post
    Why do you believe my "QString File;" is not having any global affect? And what is the standard method to share the "File" data in this case between classes?

    I feel this seems to be too much of a pain to be the correct way.
    What you create is a local variable. It is unique to the local method only. It will be discarded when the method dies.
    I am also somewhat distrusting as why you need to share this ... data between your classes?
    The idea is that a class is a unique instance of something--an object. Just as you can have a thousand cars from the same blueprint.

    Quote Originally Posted by tabstop View Post
    Because I can read. You explicitly state, by saying "QString File;" that you discard all possibility of using the global variable of the same name. It no longer exists for you to use.
    That's not entirely true.
    The global File can still be accessed via ::File.
    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.

Page 2 of 2 FirstFirst 12
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Getting an error with OpenGL: collect2: ld returned 1 exit status
    By Lorgon Jortle in forum C++ Programming
    Replies: 6
    Last Post: 05-08-2009, 08:18 PM
  2. Creating a database
    By Shamino in forum Game Programming
    Replies: 19
    Last Post: 06-10-2007, 01:09 PM
  3. deriving classes
    By l2u in forum C++ Programming
    Replies: 12
    Last Post: 01-15-2007, 04:01 PM
  4. Need help to build network class
    By weeb0 in forum C++ Programming
    Replies: 0
    Last Post: 02-01-2006, 10:33 AM
  5. Abstract class problem
    By VanJay011379 in forum C++ Programming
    Replies: 9
    Last Post: 07-31-2002, 01:30 PM

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