Solved

How to Recover this

Posted on 2003-10-29
4
202 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

[Live Webinar] The Cloud Skills Gap

As Cloud technologies come of age, business leaders grapple with the impact it has on their team's skills and the gap associated with the use of a cloud platform.

Join experts from 451 Research and Concerto Cloud Services on July 27th where we will examine fact and fiction.

Question has a verified solution.

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

Make the most of your online learning experience.
Q&A with Course Creator, Mark Lassoff, on the importance of HTML5 in the career of a modern-day developer.
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …
Starting up a Project

615 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