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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T08:27:02+00:00 2026-05-18T08:27:02+00:00

I have a class defined in a separate file and at some point I

  • 0

I have a class defined in a separate file and at some point I need to access one of the public member functions from another source file. For some reason, I forgot how to do that and compiler gives me an error.

I have classA.h with definition of class A similar to this:

class classA {
  public:
  int function1(int alpha);
}

And a separate file classA.cpp with the implementation. And then in some other file blah.cpp I include the header and try to access it like this:

 classA::function1(15);

and my compiler refuses it with error that it could not find a match for ‘classA::function1(int)’.
I use Embarcadero RAD studio 2010 if that matters.

  • 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-18T08:27:03+00:00Added an answer on May 18, 2026 at 8:27 am

    To call a ‘normal’ function, you need an instance.

    classA a;
    a.function1(15);
    

    If you want to call the function using classA:: then it needs to be static.

    classA {
      public:
        static int function1(int alpha);
    };
    
    //...
    classA::function1(15);
    

    Note that inside a static method, you can’t access any non-static member variables, for the same reason – there is no instance to provide context.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

If I have the core of a class defined in one file as public
I have some class file.h where public: bool frameSendingFinished; is defined. So in class
I have a C# file A which defined some public enum and public struct.
If I have a CoffeeScript class defined in a separate file, which I'm calling
I have a class defined as public class viewGroups extends ListActivity Somewhere in the
I have a class defined as: class Obj { public: int width, height; Obj(int
We have a class Car defined like this in a car.rb file class Car
I have defined a class A and derived a new class B from A
I have a class with two methods defined in it. public class Routines {
I have defined a variable in a separate config file: define('URL', 'someurl.co.uk'); However, when

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.