I have been doing C programming in my previous semesters, but never did C++ or any other OO language. Can somebody please guide me how to start C++ and how to start thinking OO way?
What are the differences between pointer and reference variables? How to choose one?
Given some characters and a long string text, find the shortest substring covering all given characters.
Give a string, find all the substrings that are palindrome. The lengthes of these substrings have to be odd.
In the header file you see the following declaration:
class Foo { void Bar( void ) const ; }; Tell me all you know about the Bar() function.
You can win three kinds of basketball points, 1 point, 2 points, and 3 points. Given a total score X, print out all the combination to compose X.
#include<iostream> using namespace std; class test { static int x; int *ptr; }; int main() { test t; cout<<"\n"<<sizeof(t); cout<<"\n"<<sizeof(test); }
You have an array of 1 million integers, there is at most one 5 in the array. write code to find the index of 5, or return -1 if there is no 5. The array can be put into main memory.
Given two sorted arrays, i.e., A and B, output the union and intersection of A and B.
What's the output of the following code? and why? main() { int a[5] = {1,2,3,4,5}; int *ptr = (int*)(&a+1);
printf("%d %d" , *(a+1), *(ptr-1) );
}
Given a set of N number, find the one whose occurences are big than N/2.
The input is phone #, and the output should be the corresponding string, e.g., input: 23, output:[ad, ae, af, bd, be, bf, cd, ce, cf]
What is the output of the following program?
int main() {const char* p = "12345"; const char **q = &p; *q = "abcde"; const char *s = ++p; p = "XYZWVU"; printf("%c\n", *++s); }
There is an array of integers, where every element is repeated exactly once except one element, e.g. 3 in {1,1,2,2,3,5,5}, how do you find the outlier?
If there are multiple functions in a constructor, and the destructor also contains a set of corresponding functions, how to guarantee that the destructor will be called?
Is there anything wrong with the following program?
void my_malloc (void * ptr, int size) { ptr = malloc(size); } int main () { int * ptr; int i; my_malloc(ptr, 10); for (i=0; i<10; i++) { ptr[i] = i*10; ... } free(ptr); return; }
Is there anything wrong with below C++ code?
int main() { int a, *pa, &ra; pa = &a; ra = a; cout<<"a="<<a<<"*pa="<<*pa<<"ra"<<ra ; getchar(); return 0; }
RSS link for this tag
You must log in to post.
Register or log in:
Lost Password?