jkl
BAN USER
jkl
- 0of 0 votes
Answershow to restrict creation of object inside the function fun
- jkl in India
although destructor and constructor is private??
#include <iostream>
class ABC
{
private :
~ABC()
{
}
ABC()
{
std::cout <<"ABC";
}
public:
static void fun()
{
ABC t;
}
};
int main()
{
ABC::fun();
}| Report Duplicate | Flag | PURGE
Microsoft abc - 0of 0 votes
AnswersDerived* d =new Base;
- jkl in India
// why this is not possible| Report Duplicate | Flag | PURGE
Bank of America - 0of 0 votes
Answersuse case where only namespaces can only be used in c++
- jkl in India| Report Duplicate | Flag | PURGE
Siemens Software Developer - 0of 0 votes
AnswersHow Qt achieves platform neutrality
- jkl in India| Report Duplicate | Flag | PURGE
Capgemini - -1of 1 vote
AnswersHow to register new classes in factory pattern ?
- jkl in India| Report Duplicate | Flag | PURGE
Tricon Software Developer C++
#include <stdio.h>
#include <conio.h>
#include <stdlib.h>
typedef struct tree
{
int data;
struct tree* left;
struct tree* right;
}TREE;
TREE* createNode(int x)
{
TREE *ptr;
ptr=(TREE*)malloc(sizeof(TREE));
ptr->data=x;
ptr->left=NULL;
ptr->right=NULL;
return ptr;
}
void kthLargest(TREE *root,int *kth,int k)
{
static int counter=0;
if(root==NULL)
return;
else
{
kthLargest(root->left,kth,k);
counter=counter+1;
if(k==counter)
{
*kth=root->data;
return;
}
printf("%d",counter);
kthLargest(root->right,kth,k);
}
}
int getCount(TREE *ptr)
{
if(ptr==NULL)
return 0;
else
return 1+getCount(ptr->left)+getCount(ptr->right);
}
TREE *root;
void initialize()
{
root=NULL;
}
int main()
{
initialize();
root=createNode(8);
root->left=createNode(6);
root->right=createNode(11);
root->left->left=createNode(5);
root->left->right=createNode(7);
root->left->left->left=createNode(4);
root->right->left=createNode(10);
root->right->right=createNode(13);
int kth,k;
k=5;
kth=0;
kthLargest(root,&kth,getCount(root)-k+1);
printf("\n the kth largest number =%d",kth);
return 0;
}
#include <string.h>
#include <stdlib.h>
int main(int argc, char* argv[])
{
//char ***p=**p=*p="hello";
int Hash[255];
char str[]="lxkfjglk jpdjhpfsjhrtjgv jth0t9jhy";
//memset(Hash,1,255);
int i;
for(i=0;i<255;i++)
{
Hash[i]=0;
}
for(i=0;str[i]!='\0';i++)
{
printf("\t\t %d",str[i]);
Hash[str[i]]=Hash[str[i]]+1;
printf("--> %d",Hash[str[i]]);
}
printf("hash=%d",Hash[0]);
int t=0;
for(i=0;str[i]!='\0';i++)
{
if(Hash[str[i]]>1)
{
printf("\n the first non repeating element is=%c",str[i]);
t=1;
}
if(t==1)
break;
}
return 0;
}
@ ketan :
- jkl March 23, 2016this is relevant to c++
Base is the parent class and Derived is the child class ..