c++ to c question

This is a discussion on c++ to c question within the C Programming forums, part of the General Programming Boards category; Let's make as if I have in all 5 files in my c++ program. X.hpp, Y.hpp, X.cpp, Y.cpp, main.cpp Class ...

  1. #1
    Registered User
    Join Date
    May 2006
    Posts
    19

    c++ to c question

    Let's make as if I have in all 5 files in my c++ program.
    X.hpp, Y.hpp, X.cpp, Y.cpp, main.cpp

    Class X doesn't have any data members(variables). Class Y uses a method (to do some calculation) found in class X ( let's call it myX(int ) ) and this method returns a value to class Y.

    I do this in my constructor in Class Y:
    [code]

    X aX;
    aX.myX(number);

    [\code]

    where number is a data member in class Y.


    So that means that class X won't have a struct right?

    If class X doesn't have any struct, how do i use the function myX in class Y??

  2. #2
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Code:
    some_type some_function( some_parameter )
    {
        ...do some stuff...
    
        return some_var;
    }
    
    ...
    
    struct classY some_instance;
    some_instance.some_var = some_function( some_value );
    Like so.


    Quzah.
    Hope is the first step on the road to disappointment.

  3. #3
    Registered User
    Join Date
    May 2006
    Posts
    19
    thanks a lot for your help

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Alice....
    By Lurker in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 06-20-2005, 03:51 PM
  2. Debugging question
    By o_0 in forum C Programming
    Replies: 9
    Last Post: 10-10-2004, 06:51 PM
  3. Question about pointers #2
    By maxhavoc in forum C++ Programming
    Replies: 28
    Last Post: 06-21-2004, 01:52 PM
  4. Question...
    By TechWins in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 07-28-2003, 10:47 PM
  5. Question, question!
    By oskilian in forum A Brief History of Cprogramming.com
    Replies: 5
    Last Post: 12-24-2001, 01:47 AM

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