How can assign a class value to another nested classes in C++

this is the first time to ask my question on Cplusplus. my qustion is i got this message when i trying to run this code:

object.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
#ifndef __NCTUNS_nslobject_h__
#define __NCTUNS_nslobject_h__

#include <stdio.h>
#include <event.h>

//---------------------------------------------------
#include <cstdlib>      //srand()
#include <iostream>     //cout
#include <ctime>        //time()
#include <cstring>      //strcmp()
//#include "test.h"       //testing functions
#include "RSA.h"        //GenerateKeyPair()
#include "PrimeGenerator.h"     //Generate()
//#include <stdio.h>
#include <stdlib.h>
#include <sstream>
#include <string>


//---------------------------------------------------

class MBinder;

struct plist {
u_int8_t        pid;
struct plist            *next;
};

struct MBlist {
u_int8_t    portnum;
MBinder     *sendt;
struct MBlist   *next;
};
 /*=========================================================================
 Define Macros
  =========================================================================*/
#define DISABLED        0x00
#define ENABLED         0x01


/*=========================================================================
Define Class ProtoType
=========================================================================*/

class NslObject {

private: 

char        *name_;     /* Instance name */
const u_int32_t nodeID_;    /* Node Id */
const u_int32_t nodeType_;  /* Node type, eg: SWITCH, HOST.. */
u_int32_t   portid_;    /* port Id */
struct plist    *MPlist_;
    //const  KeyPair  newKeyPair;


public :
/* add for new structure engine*/
    u_int32_t       pdepth;
    struct MBlist   *BinderList;
    u_int8_t       PortNum;

//------------------------------------------------
    static KeyPair  newKeyPair ;
    //static KeyPair  *KeyPtr1 ;//= new KeyPair;
    //------------------------------------------------
u_char          s_flowctl;      /* flow control for sending pkt */
u_char          r_flowctl;      /* flow control for receiving pkt */

MBinder     *recvtarget_;   /* to upper component */
MBinder     *sendtarget_;   /* to lower component */


NslObject(u_int32_t, u_int32_t, struct plist*, const char *);
NslObject();
virtual         ~NslObject();   
virtual int     init();
virtual int     recv(ePacket_ *); 
virtual int     send(ePacket_ *); 
virtual int     get(ePacket_ *, MBinder *);
virtual int     put(ePacket_ *, MBinder *);
virtual ePacket_    *put1(ePacket_ *, MBinder *);
virtual int     command(int argc, const char *argv[]); 
virtual int     Debugger();


inline  void    set_port(u_int32_t portid) { 
        portid_ = portid; 
    };   
inline u_int32_t get_port() const { 
        return(portid_); 
    }; 
inline struct plist* get_portls() const {
        return(MPlist_);
    };
inline const char * get_name() const {
        return(name_);
    }
inline u_int32_t get_nid() const {
        return(nodeID_);
    }
inline u_int32_t get_type() const {
        return(nodeType_);
    }
    //--------------------------------------------------------

  static  void Set_KeyPair(void);

//  NslObject(const KeyPair &newKeyPair):
//  newKeyPair(newKeyPair) {
//  }
 //NslObject( KeyPair &other, u_int32_t &N_ID, u_int32_t &N_Type) : newKeyPair(other),nodeID_     (N_ID),nodeType_ (N_Type)  {}



 /*  Key(const BigInt &modulus, const BigInt &exponent) :
modulus(modulus), exponent(exponent) {
}*/

};


/* Added by CCLin to uniformly format
* debugging messages.
*/

 #define NSLOBJ_DEBUG_STRING_HEAD() do {                \
double sec;                     \
TICK_TO_SEC(sec, GetCurrentTime());         \
printf("%11.7f: [%03d]%s::%s: ",            \
        sec, get_nid(),             \
        getModuleName(this), __FUNCTION__); \
} while(0)

 #endif /* __NCTUNS_object_h__ */ 



in Object.cc

1
2
3
4
5
6
7
8
9
void Set_KeyPair()
{
unsigned long int keyLength = 10;
//static KeyPair ADD(RSA::GenerateKeyPair(keyLength));
NslObject::newKeyPair  (RSA::GenerateKeyPair(keyLength));

//NslObject::KeyPtr
//NslObject::newKeyPair;
}



so, my problem is when the compiler starts compiling it stops on this code :

NslObject::newKeyPair (RSA::GenerateKeyPair(keyLength));

and the appeared message is :


Error:
object.cc: In function ‘void Set_KeyPair()’:
object.cc:53: error: no match for call to ‘(KeyPair) (KeyPair&)’


so, how could i assign a generated keypair class value to NslObject::newKeyPair.
your helping is highly appreciated in advance & thank you .
Should it be:
1
2
3
4
void NslObject::Set_KeyPair()
{
    //...
}
Last edited on
closed account (Dy7SLyTq)
your calling a constructor you didnt make
Topic archived. No new replies allowed.