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

  • Home
  • SEARCH
  • 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 972365
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T03:06:47+00:00 2026-05-16T03:06:47+00:00

I have to classes, an Executer with these methods: Executer() struct Execute(string s) Lookup(string

  • 0

I have to classes, an Executer with these methods:

  1. Executer()
  2. struct Execute(string s)
  3. Lookup(string name, int module, int num, …)

and a Parser:

  1. Parser()
  2. struct Parse(string s)

The Exectuers Execute method calls the Parsers Parse method. The Parser then chucks the string into smaller bits (it explodes the string on the ;-sign) and returns a struct to the Execute method. This struct it uses to call the Lookup method.
The struct that the Parse returns holds some standard information:

  1. An command name
  2. A senderId (a username, a mac address and a password)
  3. A variable number of arguments

And that is my problem. The Lookup method take variable arguments, but how do I handle the the hand over of these variable arguments by the struct? Im not an expert in C and C++. Should I mass the two classes togheter? So the Parser method could call the Execute method, sparing the struct away.
Or maybe there is a way of parsing an unknown variable of arguments at runtime? By some sort of array?

EDIT
I cant use the STL library from C++. I only use the C++ class and virtual feature. Im writing to an compiler where Im restricted to use almost all of the C libraries + the magic skills of C++ (virtual and class). SOory for not telling that right away.

EDIT 2
Im writing code to an embedded system and thereby using avr-gcc to compile my code. Thats why I cant use STL. The avr-gcc doesnt support this.

  • 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-16T03:06:47+00:00Added an answer on May 16, 2026 at 3:06 am

    Use std::vector<> or a simular container that can hold an arbitrary number of entries.

    struct {
      std::string commandName;
      sender_t senderId;
      std::vector<arg_t> arguments;
    };
    

    Edit: oh, you can’t use std::vector. In that case: use an array and store the length:

    struct {
      const char* commandName;
      sender_t senderId;
      int argumentCount;
      int maxArgumentCount; // you might not need this
      arg_t* arguments; // pointer to array of (at least) argumentCount elements.
    };
    

    Use malloc() or new() to create the array for the arguments.

    I would suggest to wrap the argumentCount, maxArgumentCount and arguments in a separate class, which can handle the malloc/new and free/delete as well. This will make it easier to prevent memory leaks.

    In the end, you’ll have written your own vector_of_arg_t class, so maybe have a look at some basic vector implementation. There must be tutorials on that on the web.

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

Sidebar

Related Questions

I have these three classes: Command: package pack; public abstract class Command impements java.io.Serializable
I have 2 decoupled classes, class A and class B, these two classes communicate
I have a C++ module that needs to get information from other classes, without
I have a 2 classes: Employee EmployeeDetails I have methods like this for Employee
I have classes A, B and C. A has members B and C. C
I have classes that are named exactly the same across different plug-ins that I
I have classes which have automatic properties only like public customerName {get; set;}. They
I have classes that are needed in both my web service and my server.
I have classes structured like this: Public MustInherit Class A ' several properties End
I have classes *ColorViewController *DrawRectangle In ColorViewController.h: #import DrawRectangle.h @interface ColorViewController : UIViewController {

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.