Thread: Spot the error?

  1. #1
    Registered User
    Join Date
    Dec 2019
    Posts
    99

    Spot the error?

    Code:
    #include<string>#include<iostream>
    using namespace std;
    
    
    void computeFeatures(string);
    
    
    int main()
    {
        string text = "Cpp is fun";
        
        computeFeatures( text );
        text += " for everyone";
        computeFeatures(text );
        
        text = "cpp fun";
        computeFeatures( text );
        text.clear();
        computeFeatures( text );
        return 0;
    }
    void computeFeature(string text)
    {
        cout << endl << "String :  " << text << endl;
        cout << "Size: " << text.size();
        cout << " Capacity:  "  << text.capacity();
        cout << "Empty?:  "  << text.empty() << endl; 
        
    }

    Code:
    /usr/bin/ld: /tmp/ccYzGeKL.o: in function `main':main.cpp:(.text+0x66): undefined reference to `computeFeatures(std::__cxx11::basic_string

  2. #2
    Registered User
    Join Date
    May 2010
    Posts
    4,632
    Spot the error?
    You've never defined a function named computeFreatures().

  3. #3
    Registered User
    Join Date
    Dec 2019
    Posts
    99
    But I copied the code word-for-word!

    Quote Originally Posted by jimblumberg View Post
    You've never defined a function named computeFreatures().

  4. #4
    Registered User
    Join Date
    Dec 2019
    Posts
    99
    Quote Originally Posted by jimblumberg View Post
    You've never defined a function named computeFreatures().
    Not saying I don't believe you!

    Just kinda curious how you would fix it....

  5. #5
    Registered User
    Join Date
    May 2010
    Posts
    4,632
    Check your spelling, C++ is quite finicky about spelling, computerFeatures is not the same as computerFeature.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 9
    Last Post: 11-30-2011, 11:55 AM
  2. Spot the error
    By Chewbacca in forum C++ Programming
    Replies: 6
    Last Post: 09-08-2002, 07:33 AM
  3. spot the error
    By razza in forum C++ Programming
    Replies: 5
    Last Post: 08-01-2002, 09:21 AM
  4. can someone help spot the error
    By blight2c in forum C++ Programming
    Replies: 6
    Last Post: 04-07-2002, 12:29 PM
  5. Spot the error
    By Snoopy in forum C++ Programming
    Replies: 8
    Last Post: 01-19-2002, 10:56 PM

Tags for this Thread