Click here to Skip to main content
15,892,005 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
HI all

i want to use structure inside the class

The way i did is

C#
testStruct.h

class testStruct
{


public:  struct msvq_param {         /* Multistage VQ parameters */
             int num_stages;
             int *num_levels;
             int *num_bits;
             int dimension;
             int num_best;
             int *indices;
             char *fname_cb;
             double *cb;
         };

};




C#
and in thetestStruct.cpp
i create object of class

testStruct testStructObj;


where ever structure is used i apply   testStructObj.msvq_param


but its not working properly

kindly guide how to use structure inside header file in side the class

and then by creating its object i can use its any where by adding header file
in that .cpp file

plz Help

Regards

Saima
Posted
Comments
CPallini 2-May-12 6:20am    
What do you mean with 'it is not working properly'?
Please elaborate.

You probably want to allocate a member of that structure in your class, for example by:

class testStruct
{
public:  
    struct msvq_param {         /* Multistage VQ parameters */
             int num_stages;
             int *num_levels;
             int *num_bits;
             int dimension;
             int num_best;
             int *indices;
             char *fname_cb;
             double *cb;
         } m_param;
};

Then you can access that member by (example)
testStructObj.m_param.stages = ...


Or your just want to access the structure definition. Then you would have to write:

testStruct::msvq_param   myParam;
 
Share this answer
 
Quote:
testStructObj.msvq_param

or rather correctly
Quote:
testStructObj::msvq_param

is a way to access the declaration of msvq_param

To utilize this structure, you should have a variable for this structure, which you can have as a protected/private member of your class
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900