Link to home
Start Free TrialLog in
Avatar of Anuradha_Sreepada
Anuradha_Sreepada

asked on

How to Recover this


void SnmpPdu :: varbinds(vector<NameValuePair>  aVarbinds) {
     //throw Exception    
          int length = aVarbinds.size();
          vector<NameValuePair> *aVarbindsPtr;
          aVarbindsPtr = &aVarbinds;
          VarbindList myVarbinds =
                              *(reinterpret_cast<VarbindList *>(aVarbindsPtr));
          for( int i = 0; i < length/*aVarbinds.size()*/; ++i ) {          varbinds().push_back(myVarbinds[i]);//Error Here
          }
}

Above is the piece of code in which i am getting error

And the error message is:
______________________

SnmpPdu.cpp: In method ' void SnmpPdu::varbinds(vector<NamValuePair,allocator<NameValuePair> >)' :
SnmpPdu.cpp:106: no match for 'VarbindList & [int &] '


Here VarbindList is a class and am writing the class declaration here and also the class declaration of NameValuePair.

Class VarbindList:
_______________

#ifndef VARBINDLIST_H
#define VARBINDLIST_H

#include "Varbind.h"
#include "Vector.h"
#include <vector.h>
#include "Snmp.h"
#include "Object.h"

class VarbindList : public Vector {

public:
VarbindList() {

static const string INVALID_OBJ = "Invalid instance";
static const string INVALID_OBJ_VEC = "Not an instance of vector";
}
VarbindList(int initialCapacity);

static VarbindList decodeSequence(Asn1Value aVarbinds);// throws

void addVarbind(Object aVarbind);// throw Exception;


void addVarbinds(vector <Object> aVarbindArray);// throw Exception;


void addVarbinds(Vector aVectorOfVarbinds);// throw Exception;


void addVarbinds(Object aVarbind);// throw Exception;


vector <Varbind> getVarbindArray();
vector <Object> encode();
char * toString();

// Constants
private:
static const string INVALID_OBJ;// = "Invalid instance";
static const string INVALID_OBJ_VEC;// = "Not an instance of vector";
};
#endif // VARBINDLIST_H

___________________
Class NameValuePair:
___________________

# ifndef NAMEVALUEPAIR_H
# define NAMEVALUEPAIR_H

#include "Snmp.h"
# include "AllIncludes.h"

class NameValuePair {
private:
string Name;
string Value;

public:
NameValuePair() { }
NameValuePair(string mName, string mValue) {
Name = mName;
Value = mValue;
}
//Get methods..
string name() { return Name; }
string value() { return Value; }

//Set Methods
void name(string mName) { Name = mName; }
void value(string mValue) { Value = mValue; }
};
# endif
ASKER CERTIFIED SOLUTION
Avatar of mrd_2k
mrd_2k

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial