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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T06:27:30+00:00 2026-05-15T06:27:30+00:00

I am trying to initialize the following array of the following struct, but my

  • 0

I am trying to initialize the following array of the following struct, but my code isn’t compiling. Can anybody help me out?

The struct/array:

struct DiningCarSeat {
    int status;
    int order;
    int waiterNum;
    Lock customerLock;
    Condition customer;

    DiningCarSeat(int seatNum) {
        char* tempLockName;
        sprintf(tempLockName, "diningCarSeatLock%d", seatNum);
        char* tempConditionName;
        sprintf(tempConditionName, "diningCarSeatCondition%d", seatNum);
        status = 0;
        order = 0;
        waiterNum = -1;
        customerLock = new Lock(tempLockName);
        customer = new Condition(tempConditionName);
    }
} diningCarSeat[DINING_CAR_CAPACITY];

The relevant errors:

../threads/threadtest.cc: In constructor `DiningCarSeat::DiningCarSeat(int)':
../threads/threadtest.cc:58: error: no matching function for call to `Lock::Lock()'
../threads/synch.h:66: note: candidates are: Lock::Lock(const Lock&)
../threads/synch.h:68: note:                 Lock::Lock(char*)
../threads/threadtest.cc:58: error: no matching function for call to `Condition::Condition()'
../threads/synch.h:119: note: candidates are: Condition::Condition(const Condition&)
../threads/synch.h:121: note:                 Condition::Condition(char*)
../threads/threadtest.cc:63: error: expected primary-expression before '.' token
../threads/threadtest.cc:64: error: expected primary-expression before '.' token
../threads/threadtest.cc: At global scope:
../threads/threadtest.cc:69: error: no matching function for call to `DiningCarSeat::DiningCarSeat()'
../threads/threadtest.cc:51: note: candidates are: DiningCarSeat::DiningCarSeat(const DiningCarSeat&)
../threads/threadtest.cc:58: note:                 DiningCarSeat::DiningCarSeat(int)

Thanks in advance!

  • 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-15T06:27:31+00:00Added an answer on May 15, 2026 at 6:27 am

    There are multiple issues here:

    These should both be pointers, since you are newing them in your constructor:

    Lock customerLock;
    Condition customer;
    

    You don’t declare a type for seatNum:

    DiningCarSeat(seatNum) {
    

    You don’t allocate memory for tempLockName or tempConditionName:

        char* tempLockName;
        sprintf(tempLockName, "diningCarSeatLock%d", seatNum);
        char* tempConditionName;
        sprintf(tempConditionName, "diningCarSeatCondition%d", seatNum);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to initialize inline an array of UInt16. For int I can do
How do I initialize a 2D array in Perl? I am trying the following
I am trying to initialize NSDictionary but it gives me following error: Program received
I am trying to initialize directX, but for some reason it can't create d3d
I am trying to understand the boost array . The code can be read
I am trying to initialize two NSArrays with the following code self.fillingTypes = [[NSArray
I'm trying to initialize a dictionary with string elements as keys and int[] elements
According to the PHP docs, one can initialize properties in classes with the following
I am trying to get the following loop working to fill an array of
I am trying to initialize a newly created empty array by using a method.

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.