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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T12:51:07+00:00 2026-06-13T12:51:07+00:00

I try to declare the following class in C++; however, I have gotten the

  • 0

I try to declare the following class in C++; however, I have gotten the following error. Is there something wrong with pointers?

class classFather{
public:
    int BmcCommand;
    int BmcDataLength;
    byte BmcDataBuffer[];

    classFather() {
        BmcCommand = 0;
        BmcDataLength = 0;
        BmcDataBuffer = new byte[CMD_LENGTHH];
    }

    classFather(byte s8Command, int siLength, byte as8Data[]) {
        BmcCommand = s8Command;
        BmcDataLength = siLength;
        int size = sizeof( as8Data ) / sizeof( as8Data[0] );
        BmcDataBuffer = new byte[size];
        for(int ii=0; ii< size; ii++)
            BmcDataBuffer[ii] = as8Data[ii];
    }
private:
    static const short CMD_LENGTHH = 255;
};

I’m getting the following error:

error: incompatible types in assignment of `byte*' to `byte[0u]'
C:\....\BluetoothClient\/msgCAN.h: In constructor `msgCANFather::msgCANFather(byte, int, byte*)':
  • 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-13T12:51:08+00:00Added an answer on June 13, 2026 at 12:51 pm

    As others said, you try to assign a pointer to an array.

    Better then writing memory leaks this way (I see a new but no delete), use a vector:

    std::vector<byte> BmcDataBuffer;
    
    Father(byte s8Command, int siLength, byte as8Data[]) {
        ...        
        BmcDataBuffer.insert( BmcDataBuffer.begin(), asData, asData+size );
        ...
    }
    

    Note:

    int size = sizeof( as8Data ) / sizeof( as8Data[0] );
    

    Will always return sizeof( byte* ) / sizeof( byte* ), i.e. 1.

    Note 2: you could use an initializer list to create the vector member in one go:

    Father(byte s8Command, int siLength, byte as8Data[]) 
    : BmcDataBuffer( asData, asData+size )
    {
    }
    

    the vector constructor will copy all asData elements.

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

Sidebar

Related Questions

I have the following class, class Simulation { public: btDefaultCollisionConfiguration collisionConfiguration; btBroadphaseInterface broadphase; btSequentialImpulseConstraintSolver
I'm looking to do something like the following: class Whatever { public: enum PhysicalObjectType
Try this code - import java.io.StringReader; public class StringReaderTest { public static void main(String[]
Try this piece of code - public class WhitespaceTest { public static void main(String[]
I have the following cyclic dependency problem I am trying to solve: typedef std::map<int,
(Java Spring WebApp) I have: public class PersonValidator implements Validator { private PersonDAO d;
Let's say I have the following snippet: template <class T> void f(T arg) {
I have the following code where I want to declare an object inside an
I have the following code and am getting this error before compiling: Fast Enumeration
I have the following associated property in my Employee class, where EmployeePhoneNumber is related,

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.