Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1038065
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T14:55:42+00:00 2026-05-16T14:55:42+00:00

I am getting an error when I declare a class: #include <iostream> #include testing/test.h

  • 0

I am getting an error when I declare a class:

#include <iostream>
#include "testing/test.h"
#include <string>
using namespace std;

int main(void)
{    
    test links;
    string content="this is an string";
    links.getcont(content);
}

test.h

#ifndef TEST_H_
#define TEST_H_
#include<string>
using namespace std;
class test {    
  public:    
    string getcont(string content); 

};

#endif /* TEST_H_ */

test.cpp

#include "test.h"
#include <iostream>
using namespace std;    
string getcont(string content)    
{
    cout << content;
    return content;
}

When I run this I get this error:

undefined reference to test::getcont(std::basic_string<char, std::char_traits<char>, std::allocator<char> >)
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T14:55:42+00:00Added an answer on May 16, 2026 at 2:55 pm

    Well , in your test.cpp file replace the getcont function for this

    string test::getcont(string content){ //code here; }
    

    The problem is that you are not saying that getcont is a member function of the test class.

    Also, consider making it a const function and passing a const string reference

    string
    test::getcont( const string& content) const
    {
        return content;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 516k
  • Answers 516k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer UIWebView should makes just what you need. - (BOOL)application:(UIApplication *)application… May 16, 2026 at 6:46 pm
  • Editorial Team
    Editorial Team added an answer It is not possible to change the src attribute before… May 16, 2026 at 6:46 pm
  • Editorial Team
    Editorial Team added an answer The reason it is not detecting published updates was due… May 16, 2026 at 6:46 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

I have written the following code: #include <iostream> using namespace std; template <class T>
I'm getting the following compile error in one of my classes, using gcc 3.4.5
I am currently getting this error: System.Data.SqlClient.SqlException: New transaction is not allowed because there
I am getting the above mentioned error when my web service tries to open
Solved When I try to compile this program i keep getting these errors: (50)
So I have this code for these Constructors of the Weapon class: Weapon(const WeaponsDB
I have a program using 3 header files and 3 .cpp files in addition
I am trying to find dynamically and statically instantiated objects number. I am getting
I want to write reusable code and need to declare some variables at the
I'm having a problem with either typecasting or object scope. I'm getting an uncaught

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.