Click here to Skip to main content
15,886,823 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: Pictures in Html Help Workshop Pin
Marc Soleda4-Sep-05 21:06
Marc Soleda4-Sep-05 21:06 
QuestionKey codes to name Pin
Gadjuka4-Sep-05 2:52
Gadjuka4-Sep-05 2:52 
AnswerRe: Key codes to name Pin
Christian Graus4-Sep-05 10:43
protectorChristian Graus4-Sep-05 10:43 
AnswerRe: Key codes to name Pin
Anonymous4-Sep-05 14:18
Anonymous4-Sep-05 14:18 
GeneralRe: Key codes to name Pin
Gadjuka4-Sep-05 23:40
Gadjuka4-Sep-05 23:40 
Question.NET Application books Pin
hcmuns4-Sep-05 1:59
susshcmuns4-Sep-05 1:59 
QuestionHow to use CByteArray to store large data into Oracle database Pin
snprani4-Sep-05 1:21
snprani4-Sep-05 1:21 
Questionneeded help for template in template problem in vc++ Pin
Member 22477494-Sep-05 1:00
Member 22477494-Sep-05 1:00 
dear friends,
I'd a problem. I want to instatite a template class like this
MaxHeap<Array<int>> m; I'm using vc++. Why it is so. The code is working if i'm changing code and using like MaxHeap<Array> m;Why it is so. How to solve this problem. Please help me in this aspect.
But compiler is giving errors like
Compiling...
heap.cpp
d:\cpppractice\sep3\heap.cpp(13) : error C2146: syntax error : missing ',' before identifier 'm'
d:\cpppractice\sep3\heap.cpp(13) : error C2065: 'm' : undeclared identifier
d:\cpppractice\sep3\heap.cpp(13) : error C2143: syntax error : missing '>' before ';'
Error executing cl.exe.

heap.obj - 3 error(s), 1 warning(s)

complete code is:

# include <iostream>
# include <Heap1.h>

using namespace std;
using namespace bhadram1;


int main()
{
int array[10]={20,12,35,15,10,80,30,17,2,1};
Array<int> a(array,10);
Array<int> a1(a);
MaxHeap<Array<int>> m;
//m.initilize(a,10,10);
//m.print();
return 0;

}

# include <iostream>

using namespace std;

namespace bhadram1
{

template<class T>

class Array
{
//friend ostream& operator<<(ostream& ostr,String& s);
protected:
int size;
T* data;

public:
Array()
{
size=1;
data=new T[1];
}
Array(int n)
{
size=n;
data=new T[size];
}
Array(int* a,int const s)
{
size=s;
data=new T[size];
for(int i=0;i<s;i++)
{
data[i]=*a++;
cout<<data[i]<<endl;
}
}
Array(Array<T>& a)
{
size=a.size;
//delete[] data;
data=new T[size];
for(int i=0;i<size;i++)
{
data[i]=a.data[i];
}
}
T& operator[](int i)
{
return data[i-1];
}



};



template<class T>

class MaxHeap
{
private:
int currentSize,maxSize;

public:
MaxHeap()
{
currentSize=0;
}
void initilize(T a,int size,int arraySize)
{
T heap(size);
for(int j=1;j<=10;j++)
{
heap[j]=a[j];
cout<<heap[j];
}
currentSize=size;
maxSize=arraySize;
for(int i=currentSize/2;i>=1;i--)
{
int y=heap[i];
cout<<"a "<<a[i]<<" y "<<y;
int c=2*(i);
cout<<"c "<<c<<" current "<<currentSize<<endl;
while(c<=currentSize)
{
cout<<"sub c "<<c<<endl;
if(c<currentSize && heap[c]<heap[c+1])
c++;
if(y>=heap[c])
break;
heap[c/2]=heap[c];
c*=2;
}
heap[c/2]=y;
}
for(i=1;i<=10;i++)
{
cout<<"final "<<heap[i]<<endl;
}

}

void print()
{

}
};
};

Thanking you,

yours sincerely,
bhadram


bhadram
AnswerRe: needed help for template in template problem in vc++ Pin
Axter4-Sep-05 1:58
professionalAxter4-Sep-05 1:58 
QuestionTransferring Data from view to view Pin
Member 15334374-Sep-05 0:04
Member 15334374-Sep-05 0:04 
AnswerRe: Transferring Data from view to view Pin
LeFauve4-Sep-05 0:47
LeFauve4-Sep-05 0:47 
GeneralRe: Transferring Data from view to view Pin
Member 15334374-Sep-05 1:55
Member 15334374-Sep-05 1:55 
QuestionHow can I compile *.lib in VC++ to dll? Pin
uumeme3-Sep-05 22:15
uumeme3-Sep-05 22:15 
AnswerRe: How can I compile *.lib in VC++ to dll? Pin
Chris Losinger4-Sep-05 5:26
professionalChris Losinger4-Sep-05 5:26 
AnswerRe: How can I compile *.lib in VC++ to dll? Pin
Gary R. Wheeler4-Sep-05 5:42
Gary R. Wheeler4-Sep-05 5:42 
QuestionConnecting to Oracle database from VC++ Pin
snprani3-Sep-05 18:55
snprani3-Sep-05 18:55 
AnswerRe: Connecting to Oracle database from VC++ Pin
Neelesh K J Jain4-Sep-05 1:41
Neelesh K J Jain4-Sep-05 1:41 
Questionpls this bug Pin
neodeaths3-Sep-05 17:50
neodeaths3-Sep-05 17:50 
AnswerRe: pls this bug Pin
Branislav3-Sep-05 22:02
Branislav3-Sep-05 22:02 
GeneralRe: pls this bug Pin
neodeaths4-Sep-05 14:41
neodeaths4-Sep-05 14:41 
AnswerRe: pls this bug Pin
normanS4-Sep-05 20:09
normanS4-Sep-05 20:09 
GeneralRe: pls this bug Pin
neodeaths5-Sep-05 7:16
neodeaths5-Sep-05 7:16 
Questionswitch vs. if Pin
JKallen3-Sep-05 16:00
JKallen3-Sep-05 16:00 
AnswerRe: switch vs. if Pin
Cliff Hatch3-Sep-05 23:10
Cliff Hatch3-Sep-05 23:10 
AnswerRe: switch vs. if Pin
Tim Smith4-Sep-05 3:30
Tim Smith4-Sep-05 3:30 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.