Solved

How to Recover this

Posted on 2003-10-29
4
199 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

A short article about problems I had with the new location API and permissions in Marshmallow
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web 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 …

734 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