Solved

How to Recover this

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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
fix34  challenge 9 97
Delphi Mdi application Child forms get behind control 7 112
wordsWithout 49 79
SUM 2 INTEGER ARRAYS INTO 1 10 58
Purpose To explain how to place a textual stamp on a PDF document.  This is commonly referred to as an annotation, or possibly a watermark, but a watermark is generally different in that it is somewhat translucent.  Watermark’s may be text or graph…
This article will show, step by step, how to integrate R code into a R Sweave document
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 …
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

706 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

17 Experts available now in Live!

Get 1:1 Help Now