Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: VC6
HI all
 
i want to use structure inside the class
 
The way i did is
 
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;
         };
 
};
 

 
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 1-May-12 23:46pm
prog786374
Comments
CPallini at 2-May-12 6:20am
   
What do you mean with 'it is not working properly'?
Please elaborate.
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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;
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

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
  Permalink  

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

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 334
1 Kornfeld Eliyahu Peter 325
2 Maciej Los 239
3 OriginalGriff 188
4 King Fisher 185
0 OriginalGriff 6,303
1 DamithSL 4,764
2 Maciej Los 4,306
3 Kornfeld Eliyahu Peter 3,914
4 Sergey Alexandrovich Kryukov 3,538


Advertise | Privacy | Mobile
Web02 | 2.8.141220.1 | Last Updated 2 May 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100