C++ instanceof



I've looked around and it turns out there isn't a C++ version of the java instanceof operator. I've also found out that using instanceof is supposed to be bad, for some reason.


So let me tell you why I want to use this instanceof operator so badly. I've got a Vector that holds two types of objects, either Manager or Casual classes, that are both derived from the base class StaffMember.


I want to display the Salary for Manager objects, and the hourlyWage and hoursWorked for the Casual object. First I have to determine whether the item in the Vector is a Manager or a Casual object. So I went looking for an instanceof operator, but no such thing exists. Then I was pointed towards the typeid() function.


I tried it out and my objects are declared as the base class StaffMember. So I think that as I am adding them to this Vector, they are being cast as StaffMembers.


So right now I'm thinking about making two seperate vectors, one for Managers and another for Casual objects. However, it just isn't in the spirit of the assessment. I'll show you some code segments and provide a link to the full project for anyone interested.


From Company.cpp



```
void Company::addStaff(StaffMember* x)
{
staffList.push_back(x);
numStaff++;
}

void Company::addStaff(Casual* x)
{
staffList.push_back(x);
numStaff++;
}
void Company::addStaff(Manager* x)
{
staffList.push_back(x);
numStaff++;
}

```

From Company.h



```
class Company
{
private:
string name;
vector<StaffMember*> staffList;
int numStaff;
public:
//Constructors
Company(string name);
Company();
//Writers
void setName(string name);
//Readers
string getName();
StaffMember* getStaff(int ID);
//Mutators
void addStaff(StaffMember* x);
void addStaff(Manager* x);
void addStaff(Casual* x);
};

```

From payroll.cpp (The client)



```
void addFour(Company* westaff)
{
westaff->addStaff(new Manager("Bill Gates", 200000));
westaff->addStaff(new Casual("Angus Cheng", 36, 19.8));
westaff->addStaff(new Manager("Fernando Alonso", 49888));
westaff->addStaff(new Manager("Nelson Piquet", 8000));
}

```

[Full listing](http:// rapidshare.com/files/215333186/payRoll.rar.html)
Since you are storing pointer to type objects why not try using polymorhism by writing a base method called displayPay() declared with the keyword virtual that would be overloaded with in each of the inherited classes. Then you can loop through the vector of pointer to StaffMembers calling the displayPay() method and the correct version of displayPay() will be called for each referenced object.
hey [@fastwayjim](/forum/u/fastwayjim)

i could reproduce the behavior. of course this should not be the case. when you start a job first the data needed for the computation is processed before being transferred to a computation instance. if there is no instance available a new one has to be started and your job gets into… you are mixing up "for all iterators i" with "for some specific kind of iterator i".

what if i decide to call foo<std::vec::intoiter<string>>? then you have a function that takes an intoiter<string>, but you tried to call it with an skip<intoiter<string>>, which is a different type. hence a type mi… method a.increment() overlaps in class b.   
 therefore, regardless of the type of the variable obj, will be called the method corresponding to the actual type of the object - that is, b.increment().  
 
this method will use the variable i, declared in the same class b and having an initial value of 10.  
 
the resulting value - 11. hi [@gianna.demetroulakos](/u/gianna.demetroulakos),

as mentioned by [@william.coulson](/u/william.coulson), the object reference not set to an instance of an object normally occurs when a variable is null.

run the code in the debug mode.

when the error occurs, check the variable which has a null value in locals tab.

warm regards,

ranjith u… I have the same problem and added this to the DbContext:



```
private void PrintStackTrace()
{
  var st = new StackTrace();
  foreach (var sf in st.GetFrames())
    Console.WriteLine($"{sf.GetMethod().DeclaringType.Assembly.GetName().Name} {sf.GetMethod().DeclaringType.Name} {sf.GetMethod().Name}");
}

```

and call this function in the contructor and Dispose of the DbContext.


It seems to be a problem, if the DbContext is added with scoped lifetime to the dependency injection. I filed an issue for that.


<https://github.com/aspnet/EntityFrameworkCore/issues/10693> In C ++ 11, the code is well defined, but may not do what you expect. Exact Effects: 21.4.5 / 2:



>  Returns: `*(begin() + pos)`
>   
> 
> 
> 
> 
>  (adsbygoogle = window.adsbygoogle || []).push({});
>  
>   
> 
> if `pos < size()`
>   
> 
> 
> 
> 
>  (adsbygoogle = window.adsbygoogle || []).push({});
>  
>   
> 
> , otherwise a reference to an object of type `T`
>   
> 
> 
> 
> 
>  (adsbygoogle = window.adsbygoogle || []).push({});
>  
>   
> 
> with a value `charT()`
>   
> 
> 
> 
> 
>  (adsbygoogle = window.adsbygoogle || []).push({});
>  
>   
> 
> ; the reference value should not be changed.
> 
> 
> 



  




 (adsbygoogle = window.adsbygoogle || []).push({});
 
  

So, if the string is not empty, it returns a reference to the beginning of the internal buffer. If empty, it returns a reference `char`
  




 (adsbygoogle = window.adsbygoogle || []).push({});
 
  

with a value `0`
  




 (adsbygoogle = window.adsbygoogle || []).push({});
 
  

whose location is implementation information. network monitor is the ideal tool for monitoring servers - it does everything real time and i think you likely need to just adjust your thresholds so you get less emails.
spiceworks inventory is not intended to be used for monitoring - you can do some aspects with it, but if you're looking for real time monitoring, you're probably best off finding another tool.  if you want to do asset management and keep an eye on the devices for things like disk space, then we're going to be a good fit.  for 500 workstations, if you can avoid using the agent and just directly scan them, you will be better off from a performance standpoint - assuming the environment is fairly consistent, once you figure out how to scan one workstation, those changes should likely apply to the rest (maybe via gpo).  
i hope this helps somewhat.
jackie. if you want each cart item to to have each selected employee,

pass item to select\_emplyee(i) method not index for ex. (click)=“select\_emplyee(item)”.

then in implementation add one more extended property to your cartlist json called employeename.

select\_emplyee(item) {



this.employee\_alert… Dear **[an22560478,](https://forums.adobe.com/people/an22560478)​**

I don't think we can use Numeric Operators on eVars. Someone might has some other ideas, lets wait for them.

Yes, you can bucket the eVars from Client End, but if you need to understand/compare an individual eVar score (Let's say 1250), it is not possible. So i would recommend for Classification!

Thank You

Arun




[View solution in original post](/t5/adobe-experience-cloud-mobile/how-to-send-events-numeric-evars-from-android-sdk/m-p/257132#M761) not sure i understood. are you having problems with this code?

if yes, i think you’re using the wrong comparison operator (not = but ==).