Thread: Can you tell me why I get this compile error?

  1. #1
    Registered User
    Join Date
    Oct 2007

    Can you tell me why I get this compile error?


    I have wrote this test program for trying different things with c++ and when I pass a character array to a member function, the compiler complains.

    Here is the code:
    #include <stdio.h>
    #include <string.h>
    class Account
    char customer[251];
    char accountNumber[16];
    int balance;
    int changeCustomerInfo(char c[]);
    int main()
    char s[20] = "  This is test";
    int num = 8;
    Account test;
    num = test.changeCustomerInfo(s);
    return 0;
    int changeCustomerInfo(char c[])
     return 0;
    and the error message the compiler gives is:

    /tmp/ccy4EJL2.o: In function `main':
    2.cpp.text+0x6e): undefined reference to `Account::changeCustomerInfo(char*)'
    collect2: ld returned 1 exit status

    I've tried many things, but I can't figure out what is preventing it from compiling properly, can you tell me what my mistake is?

    Thank You!

  2. #2
    Registered User
    Join Date
    Nov 2005
    int Account::changeCustomerInfo(char c[])
     return 0;

  3. #3
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    You never wrote a function called "Account::changeCustomerInfo(char *)". You did write one called "::changeCustomerInfo(char *)", but that's clearly not the same thing.

  4. #4
    Join Date
    Oct 2007
    Inside my computer
    You also need to learn to indent code. It's not difficult, you know. Plenty of info/guides/tutorials on the web.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Beginner Needs help in Dev-C++
    By Korrupt Lawz in forum C++ Programming
    Replies: 20
    Last Post: 09-28-2010, 01:17 AM
  2. An error is driving me nuts!
    By ulillillia in forum C Programming
    Replies: 5
    Last Post: 04-04-2009, 09:15 PM
  3. DX - CreateDevice - D3DERR_INVALIDCALL
    By Tonto in forum Game Programming
    Replies: 3
    Last Post: 12-01-2006, 07:17 PM
  4. error: template with C linkage
    By michaels-r in forum C++ Programming
    Replies: 3
    Last Post: 05-17-2006, 08:11 AM
  5. Problem with Visual C++ Object-Oriented Programming Book.
    By GameGenie in forum C++ Programming
    Replies: 9
    Last Post: 08-29-2005, 11:21 PM