[try Beta version]
Not logged in

 
Overloaded brain - not function

Nov 22, 2009 at 5:32pm
CAn some body please help me out by telling me what I am not doing right here;I thank you very much in advance,

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#include <iostream>
using namespace std;

void printTriangle(int);
void drawBar(int);
void printTriangle(int, char);
void drawBar(int, char);

int main()
{
    int size = 0;
    cout << "This program draws a Triangle";
    cout << "Enter the Triangle base size: " << endl;
    cin >> size;

    printTriangle(size);
    return 0;
}
void printTriangle(int sz)
{
    for (int i = 0; i <= sz; i++)
    {
      drawBar(i);
      cout << endl;
    }
      return;
}
void drawBar(int s)
{
    for(int i = 0; i <= s; i++)
    {
        cout << "*";
    }
    cout << endl; 

    return;
}
void printTriangle(int ss, char symbol)
{
    cout << "Enter a character: ";
    cin >> symbol;

    for(int i = 0; i <= ss; i++)
    {
        cout << "symbol" << symbol   << endl;
    }
    return;
}
void drawBar(int ss, char c)
{
    cout << 'c';
    for(int i = 0; i <= ss; i++)
    {
        cout << 'c';
    }
    cout << endl;
    
    return;

}



The problem is when I go to run this only the first triangle displays. Here is a little about what it is supposed to do.


Create a function that tests both version of the drawbar function to ensure they work correctly. Each of your drawbar functions should draw a triangle, so your program solution should output two triangles.
Nov 22, 2009 at 9:21pm
You're only calling one of the print triangle functions...
Nov 22, 2009 at 9:30pm
Each of your drawbar functions should draw a triangle


*stabs your teacher for teaching students horrible naming practices*

If the function draws a triangle, it should be called drawtriangle.

grumble grumble grumble
Nov 24, 2009 at 1:25pm
Remove line 24, you are already printing the newline in drawBar
Replace line 45 with an appropriate call of drawBar
Remove line 51, on line 54 you should print c variable, not 'c' ( character literal )
You are never calling the second overload of drawTriangle in main.
Nov 24, 2009 at 3:05pm
You did not call the overload function .
You just called one of them,
and you should pass right parameter,

contains the number of the parameters and the type of the parameters
Topic archived. No new replies allowed.