declaration two class problem

This is a discussion on declaration two class problem within the C++ Programming forums, part of the General Programming Boards category; Hello (I'm new to object oriented programming) I have a class a where I declare a variable Code: class A ...

  1. #1
    Registered User
    Join Date
    Apr 2012
    Posts
    57

    declaration two class problem

    Hello
    (I'm new to object oriented programming)
    I have a class a where I declare a variable




    Code:
    class A { private: int x; }

    I have declared another class B in the project but in a different file

    when I use x it tells me that it isn't declared.

    How can I declare x so that it is visible to B?

  2. #2
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,755
    Original and translated here -> problème declaration entre deux class
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Problem with friend class declaration in a namespace
    By Angus in forum C++ Programming
    Replies: 2
    Last Post: 12-09-2008, 01:29 PM
  2. Class Declaration
    By enjoy in forum C++ Programming
    Replies: 4
    Last Post: 03-10-2006, 10:59 AM
  3. Replies: 7
    Last Post: 05-26-2005, 11:48 AM
  4. Replies: 2
    Last Post: 04-06-2005, 08:25 AM
  5. Class Declaration?
    By Unregistered in forum C++ Programming
    Replies: 1
    Last Post: 07-27-2002, 10:09 PM

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