Developer Program Engineer Interview Report
- 0of 0 votes
Answers) If you have class B which inherits from class A, the two values printed below might be different. Why?
- Gone June 01, 2011
B *myPointer = new B();
A *myOtherPointer = myPointer;
printf(“%x”, myPointer);
printf(“%x”, myOtherPointer);| Report Duplicate | Flag | PURGE
Developer Program Engineer - 0of 0 votes
AnswersWhy doesn’t this work?
- Gone June 01, 2011
#include <iostream>
#include <string.h>
using namespace std;
void newBuffer(char* outBuffer, size_t sz) {
outBuffer = new char[sz];
}
int main(void) {
const char* kung = "KUNG";
char* foo;
size_t len = strlen(kung);
newBuffer(foo, len);
memset(foo, 0, len+1);
strncpy(foo, kung, len);
cout << foo << endl;
return 0;
}| Report Duplicate | Flag | PURGE
Developer Program Engineer
CareerCup is the world's biggest and best source for software engineering interview preparation. See all our resources.