Help with code

0 The Armageladon · February 9, 2015
Hi,

i 've watched the whole C++ tutorial for my exams,but i have a hard time solving a problem so,any help would be great.
I have the following main function:


#include "tuple.h"
#include <iostream>
#include <string>

using namespace std;

int main() {
    Tuple<int, 3> t1(8), t2(9), t3(t2);

    t1.print(); t2.print(); t3.print();   // to be print: < 8 8 8 >, < 9 9 9 >, < 9 9 9 >.
    t1[0] = 1; t2[1] = 2;
    t1.print(); t2.print(); t3.print();   // to be print: < 1 8 8 >, < 9 2 9 >, < 9 9 9 >.
    t3 = t1 + t2;
    t1.print(); t2.print(); t3.print();   // to be print: < 1 8 8 >, < 9 2 9 >, < 10 10 17>.
    Tuple<string, 2> s1("a"), s2("b"), s3(s2);
    s1.print(); s2.print(); s3.print();   // to be print: < a a >, < b b >, < b b>.
    s1[0] = "c"; s2[1] = "d";
    s1.print(); s2.print(); s3.print();   // to be print: < c a >, < b d >, < b b>.
    s3 = s1 + s2;
    s1.print(); s2.print(); s3.print();   // to be print: < c a >, < b d >, < cb ad >.
    return 0;
}

I must write the appropriate code in order to get what is commented.The only inline method must be " operator[ ] ".

Any help?

Post a Reply

Replies

Oldest  Newest  Rating
0 Mathias Frits Rørvik · February 9, 2015
Hi, I don't think you should post exams or parts of exams on an online discussion forum. This may count as academic dishonesty, and can have severe consequences for your academic career. 
0 The Armageladon · February 9, 2015
it's not an exam.It's prepatation for exams...
  • 1

C++

106,997 followers
About

Used in many types of software including music players, video games, and many large scale applications.

Links
Moderators
Bucky Roberts Administrator