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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T14:36:03+00:00 2026-06-01T14:36:03+00:00

I created a class in C++ called Commands (file name commands.cpp). I’ve taken that

  • 0

I created a class in C++ called Commands (file name commands.cpp).

I’ve taken that and put it into a command array (file name test.cpp).

What I would like to know is how to call the functions that are within the Commands class.

for example I have a function within the Commands class
called

     void command::init(char data[]) 
      {
        //detail
       }

and what i have tried to do to call the function is

EDIT

  Class test{
     int CmdCount;     // number of commands in the array
     int MaxCmds;      // max amount of commands allowed
     command* cmds;
  Public:
     int get_command_count() const{
          return CmdCount;
     }

     int readfile(const char fname[]){
          char line[161];

          FILE* fp;
          fp = fopen(fname, "r");

          if(fp){
               for(int i = 0; 1 == fscanf(fp, "%160[^\n]\n", line; i++){
                     cmds[get_command_count()].init(line);
                     CmdCount += 1;
               }
          }
          fclose(fp);
     }
  };

I just want to know how to be able to call void command::init(char data[]).

Any suggestions?

thanks.

  • 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-01T14:36:04+00:00Added an answer on June 1, 2026 at 2:36 pm

    Sounds like your array contains instances of your class. In that case you want to call the method on a single entry in the array:

    my_array[i].someMethod();
    

    where my_array[i] is an instance of your class.

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

Sidebar

Related Questions

I created a two class named Vendor and Address in one file called business.groovy(that
I have an entity called File, I created a partial class with a property
I have created UITableCellView class called NoteCell . The header defines the following: #import
I've a created a class called Animal as shown below: class Animal{ int eyes,legs;
I have created a class library called AddServiceLibrary in which I have a method
I have created my own button class called custom_btn. I created it on the
I have a peculiar problem. I created a normal Objective C class called SampleTable.
I'm programming in C#. I'm trying to make a class, that when called will
I created a domain class called Money, with 3 fields. I did a generate-all.
I would like to create a class whose methods can be called from multiple

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.