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 8439349
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T07:59:16+00:00 2026-06-10T07:59:16+00:00

I am new in C++ and I have a basic question for you. It

  • 0

I am new in C++ and I have a basic question for you. It must be basic, I think… 🙂 .

Here is the code that I expect to work but it does not.

char* deneme = Tool::getStringIntoArray("Hello");

I want to get an char array from a static function in the class ‘Tool’ by passing a string into it.

Here is my Tool header:

#include <string>
using namespace std;

#ifndef TOOL_H_
#define TOOL_H_

class Tool
{
public:
    static char* getStringIntoArray(string);
};

#endif

I have learnt that the only thing to use that function is to give a keyword which is ‘static’ there.

Finally, the Tool.cpp for the function:

#include "Tool.h"

char* getStringIntoArray(string str)
{
    int* size = new int(str.size());
    char* array;
    array = new char[*size];

    for ( int i = 0; i < *size; i++) {
        array[i] = str[i];
    }

    delete size;
    return array;
}

Nevertheless it works in the source file where the first code that I gave but when I put this function into a class for static usage, it does not work. The error is shown below :

undefined reference to `Tool::getStringIntoArray(std::basic_string<char, std::char_traits<char>, std::allocator<char> >)' 

Thx.

  • 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-06-10T07:59:17+00:00Added an answer on June 10, 2026 at 7:59 am

    undefined reference to `Tool::getStringIntoArray(std::basic_string, std::allocator >)’

    It’s looking for Tool::getStringIntoArray but you defined getStringIntoArray.

    Change the signature in the definition from

    char* getStringIntoArray(string str)
    

    to

    char* Tool::getStringIntoArray(string str)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've look at this question and I must say that it does not fit
I am new to Hadoop/PIG. I have a basic question. Do we have a
I'm relatively new to SVN and have a rather basic question. I have several
I'm new to android apps development and I have a basic sqlite question. What
Forgive me, I'm new to Java and have an extremely basic question. I have
I'm new to C++, so this question may be basic: I have two classes
I have a basic question that's driving me crazy. I have a class inheriting
I am new to javascript and have a very basic question: I have this
I am new to .NET so I have a basic question to ask, is
I'm very new to ruby & Sinatra and I have a basic question: The

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.