|
-
Feb 20th, 2003, 02:12 PM
#1
Thread Starter
Junior Member
function prototype and definition question
Im a beginner in C++ and I have this program here:
#include <iostream>
#include <vector>
#include <cmath> //abs()
using namespace std;
void RotateLetters (vector <char> & CharList, int NumPositions);
int main (void)
{
vector <char> Alphabet (26);
for (int cnt = 0; cnt < 26; cnt++)
Alphabet [cnt] = char (cnt + ‘A’);
cout << “How many positions do you intend to rotate this alphabet list? “
<< “ ‘-‘ means rotate upward; otherwise downward.” << endl;
int Positions;
cin >> Positions;
RotateLetters (Alphabet, Positions);
for (cnt = 0; cnt < Alphabet.size(); cnt++)
cout << Alphabet[cnt];
cout << endl;
return 0;
}
//Purpose: Rotate the letters in CharList either upward or downward depending
// on the sign of the integer argument
//Precondition: CharList is a char vector containing the 26 alphabetical letters,
// NumPositions is the desired position for the 26 letters to rotate –
// ‘+’ or no sign => downward and ‘-‘ => upward
//Postcondition: The CharList vector is rotated accordingly
void RotateLetters (vector <char> & CharList, int NumPositions)
How do I supply the function prototype and definition for the function RotateLetters() ????
-
Feb 20th, 2003, 02:55 PM
#2
Member
Well you already have the function's prototype. You just need to give it's definition.
Like so.
Code:
void RotateLetters (vector <char> & CharList, int NumPositions)
{
// Rotate characters here.
return;
}
It is defined in the same manner as main().
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|