OOD (Object Oriented Design) Question on "class"

The below code is giving me an error. I'm cannot find the problem. I'm listing the code and the errors Xcode is giving me.

I'm trying to write the definition of the method in my class called "func()". I'm suppose to set the values of u and w to u = 10 and w = 15.3. Any ideas to what i'm doing wrong that is producing the following errors.


THE ERROR MESSAGE:

1
2
3
4
5
6
7
8
9
10
Ld /Users/shaneyost/Library/Developer/Xcode/DerivedData/Class-giwnenmhkdglsoetwznfoarxdnqg/Build/Products/Debug/Class normal x86_64
    cd "/Users/shaneyost/Desktop/NEST/XCODE FILES/Class"
    setenv MACOSX_DEPLOYMENT_TARGET 10.8
    /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ -arch x86_64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk -L/Users/shaneyost/Library/Developer/Xcode/DerivedData/Class-giwnenmhkdglsoetwznfoarxdnqg/Build/Products/Debug -F/Users/shaneyost/Library/Developer/Xcode/DerivedData/Class-giwnenmhkdglsoetwznfoarxdnqg/Build/Products/Debug -filelist /Users/shaneyost/Library/Developer/Xcode/DerivedData/Class-giwnenmhkdglsoetwznfoarxdnqg/Build/Intermediates/Class.build/Debug/Class.build/Objects-normal/x86_64/Class.LinkFileList -mmacosx-version-min=10.8 -stdlib=libc++ -o /Users/shaneyost/Library/Developer/Xcode/DerivedData/Class-giwnenmhkdglsoetwznfoarxdnqg/Build/Products/Debug/Class

Undefined symbols for architecture x86_64:
  "xClass::xClass()", referenced from:
      _main in main.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)





THE CODE:


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#include <iostream>
using namespace std;

class xClass
{
private:
    int u;
    double w;
public:
    void func();
    void print() const;
    xClass ();
    xClass (int,double);
};

int main()
{
    cout << "TEST\n\n";
    xClass x;
    
    cout << "TEST\n\n";
    
    x.func();

    return 0;
}

void xClass::func()
{
    int U;
    double W;
    
    U=10;
    W=15.3;
    
    u = U;
    w = W;
}


You defined some functions in your class, where did you implement these functions?

1
2
3
    void print() const;
    xClass ();
    xClass (int,double);


I haven't even wrote the definition of them yet. So i'm taking it that when designing a class you have to write the definition for all functions "methods" before the program will compile?
Not necessarily all of the functions, just the functions that you are actually using. The problem you are having is that you are trying to use a class where you defined the class constructors, but haven't implemented them.
Topic archived. No new replies allowed.