Why on earth is Xcode *&^% acting up???

This is a discussion on Why on earth is Xcode *&^% acting up??? within the Tech Board forums, part of the Community Boards category; I've been using Xcode for quite some time now, and I just installed it on my MacBook (I had it ...

  1. #1
    User
    Join Date
    Jan 2006
    Location
    Canada
    Posts
    498

    Why on earth is Xcode *&^% acting up???

    I've been using Xcode for quite some time now, and I just installed it on my MacBook (I had it installed before, but I accidently erased my hard disk). Now I'm just trying to rewrite my game engine, so I started off with a simple cPoint2D class.

    When I try to compile it, the linker keeps failing because "all the symbols in cPoint2D are undefined". I checked to make sure that cPoint2D.cpp was getting compiled, and it was. Then I tried moving all the code into main.cpp, and the problem went away. So, I figure this is more of a compiler issue than with my code, so I posted it here in the Tech Board.

    But I just don't get it.......

    Here is my code, just for you to observe:
    Please do not criticize me for bad class design. This is a work in progress.

    cPoint3D.h:
    PHP Code:
    // cPoint2D - basic class for 2D points
    #ifndef CPOINT2D_H
    #define CPOINT2D_H

    #include <iostream>
    using namespace std;

    template <class T>
    class 
    cPoint2D {
        public:
        
    T xy;
        
        
    T operator*(cPoint2D<T> &value);
        
    cPoint2D<Toperator+(cPoint2D<T> *value);
        
    void print();
    };

    typedef cPoint2D<floatcfloat2D;
    typedef cPoint2D<int>   cint2D;

    #endif 
    cPoint2D.cpp:
    PHP Code:
    // cPoint2D - basic class for 2D points
    #include "cPoint2D.h"

    template <class T>
    T cPoint2D<T>::operator*(cPoint2D<T> &value) {

        return 
    x*(value->x) + y*(value->y);
    }

    template <class T>
    cPoint2D<TcPoint2D<T>::operator+(cPoint2D<T> *value) {
        
    value->+= x;
        
    value->+= y;
        return 
    value;
    }

    template <class T>
    void cPoint2D<T>::print() {

        
        
    cout << "cPoint2D: x=" << << "; y=" << << endl;

    Basically, the compiler doesn't cough on this; it's just whenever I try to call any of the member functions from cPoint2D that I get a linker error saying that the function is undefined.

  2. #2
    Just Lurking Dave_Sinkula's Avatar
    Join Date
    Oct 2002
    Posts
    5,006
    7. It is easier to write an incorrect program than understand a correct one.
    40. There are two ways to write error-free programs; only the third one works.*

  3. #3
    User
    Join Date
    Jan 2006
    Location
    Canada
    Posts
    498
    Gee, thanks!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Asteroid almost hit the earth on Monday
    By VirtualAce in forum A Brief History of Cprogramming.com
    Replies: 19
    Last Post: 03-06-2009, 10:37 PM
  2. Nice vistas with the equivalent Google Earth version
    By DavidP in forum A Brief History of Cprogramming.com
    Replies: 5
    Last Post: 08-14-2008, 06:58 AM
  3. The God Of War Is Visiting The Earth!
    By ammar in forum A Brief History of Cprogramming.com
    Replies: 6
    Last Post: 08-28-2003, 02:15 AM
  4. God
    By datainjector in forum A Brief History of Cprogramming.com
    Replies: 746
    Last Post: 12-22-2002, 11:01 AM

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