Find the Errors

Hello Everyone,

So for my C++ class, the teacher gave this out as extra credit. There are 5 errors in this code, we have to find the errors but we cannot move, add, or delete any of the logic. I have found what I think are obvious errors, but wanted to see if there's anything I'm missing? It's been over a year since I've taken any C++ class so I'm really rusty at this.

#include <iostream>

using namespace std;

template <class T>
class Test
{
public:
Test(T);
void Print();
private:
T Variable;
};

Template <class T> //"Template" should be "template"
Test<T>::Test(T InValue)
{
Variable = InValue;
}

template <T>
void Test<template T>::Print()
{
cout << Variable << endl;
}

template <> //There should be a <T>
class Test char[50]>
{
public:
Test(char [50]);
void Print();
private:
char Variable[50];
};

Test<char[50]>::Test(char InValue[50] )
{
strcpy_s(Variable, InValue);
}

void Test<char[50]>::Print()
{
cout << Variable << endl;
}

void main()
{
Test(int> objInteger(0); //The "(" should be a "<"
Test<float> objFloat(1.1);
Test<char> objCharacter('a');
Test<char[50]> objCharacterArray("Test Sentence.");

objInteger.Print();
objFloat.Print();
objCharacter.Print();
objCharacterArray.Print();
}

/*
0
1.1
a
Test Sentence.
*/
strcpy_s missing parameter numberOfElements.
Topic archived. No new replies allowed.