Hello. I'm currently wrapping up on a project which uses a doubly linked list toolkit to work with a sequence class. During which I can't get my copy constructor to function with my given driver (can't change driver)
I get this code
error C2274: 'function-style cast' : illegal as right side of '.' operator
Below i will include both my driver and my sequence implementation. However also in this program is my dnode.h and dnode.cpp(implement) files with the following functions to aid
#include<iostream>
#include <cctype> // Provides toupper
#include <cstdlib> // Provides EXIT_SUCCESS
#include"sequence2.h"
usingnamespace std;
// PROTOTYPES for functions used by this test program:
void print_menu( );
// Postcondition: A menu of choices for this program has been written to cout.
char get_user_command( );
// Postcondition: The user has been prompted to enter a one character command.
// The next character has been read (skipping blanks and newline characters),
// and this character has been returned.
double get_number( );
// Postcondition: The user has been prompted to enter a real number. The
// number has been read, echoed to the screen, and returned by the function.
sequence cctest(const sequence & source);
int main( )
{
sequence test, test2; // A sequence that we'll perform tests on
char choice; // A command character entered by the user
dnode * head = NULL;
cout << "I have initialized an empty sequence of real numbers." << endl;
do
{
print_menu( );
choice = toupper(get_user_command( ));
switch (choice)
{
case'!': test.start( );
break;
case'+': test.advance( );
break;
case'-': test.moveback();
break;
case'=': test2 = test;
test2.show_sequence();
break;
case'?': if (test.is_item( ))
cout << "There is an item." << endl;
else
cout << "There is no current item." << endl;
break;
case'C': if (test.is_item( ))
cout << "Current item is: " << test.current( ) << endl;
else
cout << "There is no current item." << endl;
break;
case'X': test.sequence( ); // ERROR ON THIS LINE
cout << "Testing the copy function" << endl;
break;
case'P': test.show_sequence();
break;
case'S': cout << "Size is " << test.size( ) << '.' << endl;
break;
case'I': test.insert(get_number());
break;
case'A': test.attach(get_number());
break;
case'T': test.tail();
break;
case'R': test.remove_current( );
cout << "The current item has been removed." << endl;
break;
case'D': test.~sequence();
break;
case'Q': cout << "Ridicule is the best test of truth." << endl;
break;
default: cout << choice << " is invalid." << endl;
}
}
while ((choice != 'Q'));
return EXIT_SUCCESS;
}
void print_menu( )
{
cout << endl; // Print blank line before the menu
cout << "The following choices are available: " << endl;
cout << " ! Activate the start( ) function" << endl;
cout << " + Activate the advance( ) function" << endl;
cout << " - Activate the moveBack() function" << endl;
cout << " = Activate the operator= function" << endl;
cout << " ? Print the result from the is_item( ) function" << endl;
cout << " C Print the result from the current( ) function" << endl;
cout << " X Activate the Copy Constructor" << endl;
cout << " P Print the entire sequence" << endl;
cout << " S Print the result from the size( ) function" << endl;
cout << " I Insert a new number with the insert(...) function" << endl;
cout << " A Attach a new number with the attach(...) function" << endl;
cout << " T Activate the tail() function" << endl;
cout << " R Activate the remove_current( ) function" << endl;
cout << " D To destory the list(destructor)" << endl;
cout << " Q Quit this test program" << endl;
}
char get_user_command( )
{
char command;
cout << "Enter choice: ";
cin >> command; // Input of characters skips blanks and newline character
return command;
}
double get_number( )
{
double result;
cout << "Please enter a real number for the sequence: ";
cin >> result;
cout << result << " has been read." << endl;
return result;
}
sequence cctest(const sequence & source)
{
sequence test(source);
return test;
}