Solved

How to Recover this

Posted on 2003-10-29
4
196 Views
Last Modified: 2010-04-17

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
0
Comment
Question by:Anuradha_Sreepada
4 Comments
 
LVL 2

Accepted Solution

by:
mrd_2k earned 20 total points
ID: 9648099
i think you need to include the appropriate class member function declarations in your derived class, like the [] overloaded operator, since the original functions weren't declared as virtual. although i'm tired and unsure, so give it a whirl ;)
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Report events not being triggered 8 113
endX challenge 2 63
create an incrementing variable name AutoHotKey 5 76
eclipse package explorer vs project explorer view 2 79
If you’re thinking to yourself “That description sounds a lot like two people doing the work that one could accomplish,” you’re not alone.
Although it can be difficult to imagine, someday your child will have a career of his or her own. He or she will likely start a family, buy a home and start having their own children. So, while being a kid is still extremely important, it’s also …
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now