Mixing C++ class and non-class code?

This is a discussion on Mixing C++ class and non-class code? within the C++ Programming forums, part of the General Programming Boards category; Hi, I am building a Qt C++ application, and bumped into this issue. Usually all my files are classes, and ...

  1. #1
    Registered User
    Join Date
    Dec 2007
    Posts
    3

    Mixing C++ class and non-class code?

    Hi, I am building a Qt C++ application, and bumped into this issue.

    Usually all my files are classes, and to use a class from another I'd simply include the header file and it's done.

    Now I have this c++ module, say A, it has only 2 files, A.cpp and A.h. Unlike my other files A is not a class, it is just like a c module. Say class B wants to use functions in A, I've tried including A.h in B, but it gets an undefined reference error when I try to compile it... I could turn A into a class and make all its functions static, but I am wondering if you can just call to it directly and use its functions...

    Not sure if I worded it clear, I'll post some code if it's necessary.

    Thanks.

    ----
    EDIT:
    I've just found out how to do it properly... it'd be good if the topic can be closed or deleted.
    Last edited by Depthcharge101; 05-26-2009 at 11:30 PM. Reason: resolved

  2. #2
    Algorithm Dissector iMalc's Avatar
    Join Date
    Dec 2005
    Location
    New Zealand
    Posts
    6,293
    There's no reason for it not to work unless you've done something weird.
    You'll have to show an example.

Popular pages Recent additions subscribe to a feed

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