btech 0 Light Poster

I am trying to setup a simple (or so i thought) vpn connection. the static ip address is added to a netgear router and port forward is configured to a server 2003 machine with rrap. there are 2 nics in the server and they are configured LAN 192.168.1.4 and WAN 192.168.0.7. The routers internal ip is 192.168.1.1. everything looks to be setup correctly but am unable to establish a connection.

btech 0 Light Poster

Why don't you write some test programs for yourself to create trees with varying degrees of unbalance to test the function.

I have tried but keep receiving errors

#include <iostream>
#include "avlTree.h"

using namespace std;

int main()
{
	AVLNode<int> avlTree;

	int num;

	cout << "Enter integers ending with -999" << endl;

	cin >> num;
	while(num != -999)
	{
		cin>>num;
	}
            cout << avlTree.check();

	return 0;
}
btech 0 Light Poster

I want to check to see if a binary tree is perfect. this means that the height of the left and right subtrees of the root are equal and the left and right subtrees of the root are perfectly balanced binary trees. I have written the function but am not sure it is correct. can someone please check my algorithm?

template<class elemType>
int check(AVLNode<elemType>* &root) 
{
        int height = 0;
        int lh = 0;
        int rh = 0;
        if (node == null) {
            return height;
        }
        if (root->llink != null) {
            lh = check(root->llink);
        }
        if (root->rlink != null) {
            rh = check(root->rlink);
        }
        if (root->bfactor != (rh - lh)) {
            return 0;
        }
        if (lh > height) height = lh;
        if (rh > height) height = rh;
        return ++height;
    }
btech 0 Light Poster

Below is my assignment. If I understand this correctly pivot as a median is the middle of the highest, middle, and lowest numbers. In this case 35 (14, 35, 72). Please correct me if I am wrong. I do not understand how to do part b. Could someone please explain this as well? Thank you in advance.

assume the following list of keys

18, 40, 16, 82, 64, 67, 57, 50, 37, 47, 72, 14, 17, 27, 35

This list is to be sorted using the quick sort algorithm. Use pivot as the median of the first, last and middle elements of the list.

a. what is pivot?
b. give the resulting list after one call to the partition procedure.

btech 0 Light Poster

Quadratic probing uses a quadratically growing increment that's added to the address. So if you have address 30, you would start with an increment of 1. If 31 is occupied, you square the increment to 2 and try address 33. If 33 is occupied, you square the increment to 4 for address 37, then to 16 for address 53, then to 256 for address 309. But because that would be well beyond the limits of the table, you wrap around and around until you've shucked off the extra numbers and that would give you address 6. Repeat as necessary, but if you get too many collisions, the table is probably too full to be efficient.

Then from what you are saying the item "30" will be inserted into position 53. Is this correct?

btech 0 Light Poster

I have a question about hashing. If you have a hash table that is 101 in size. and the items are inserted into the table using quadratic probing. I want to insert a new item with address 30. If position 30 in the hash table is occupied and the next 4 positions are also occupied, where in the table will the item be inserted.

If I understand quadratic hashing The first rehash adds 1 to HashValue, the second rehash adds 4, and the third rehash adds 9, and so on. So my question is would the position be 39?

btech 0 Light Poster

changed the while to for and no more crashes but still prefix instead of postfix ... any ideas?

case ')' : for ( stack.top() != '(' ){
					rpnExp += stack.top();
					stack.pop();
					}
					stack.pop();
					break;
      default :
		 for ( !stack.isEmptyStack() && precedence( infix[i]) <=  precedence( stack.top() ) ){
	    rpnExp += stack.top();
	    stack.pop();
	  } 
	  stack.push( infix[i] );
btech 0 Light Poster

made a few changes now the program outputs in prefix (i need postfix) and crashes if i use parenthesis? can someone look at the code and tell me what i am doing wrong? same .h file posted above

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

using namespace std;

int precedence (char x );
string rpn(string infix);

int main()
{
  string infix;
  
  cout << "Note: Enter ! for infix expression to exit." << endl;
  for (;;)
  {
    cout << "Infix Expression?  ";
    getline(cin, infix);
    if (infix == "!") break;
	cout << "RPN Expression is: " << rpn(infix) << endl;
  } 
  return 0;
}

int precedence (char x )
{
  switch ( x ) {
    case '+':
    case '-':
	return 1;
    case '*':
    case '/':
	return 2;
  }
  return 0;
}

string rpn(string infix)
{
  string rpnExp;
  stackType<char> stack;
  
  for (unsigned i = 0; i < infix.length(); i++)
  {
    switch(infix[i])
	{
      case ' ' : break;

      case '(' : stack.push(infix[i]);
                 break;

      case ')' : while ( stack.top() != '(' ){
					rpnExp += stack.top();
					stack.pop();
					}
					stack.pop();
					break;
      default :
		  while ( !stack.isEmptyStack() && precedence( infix[i]) <=  precedence( stack.top() ) ){
	    rpnExp += stack.top();
	    stack.pop();
	  } 
	  stack.push( infix[i] );
	}									
}
	
  while ( !stack.isEmptyStack() ) {
			rpnExp += stack.top();
			stack.pop();
		}

 return rpnExp;
}
btech 0 Light Poster

Thoughts: case ')': Should probably output all ops untill a '(' is found on the stack.

This is exactly what i am looking to do below is the algorithm for this assignment. I think I am on the right path just a little lost. Please help me figure out tje next step.

Note: Uses a stack to store operators.
1. Initialize an empty stack of operators.
2. While no error has occurred and the end of the infix expression has not been reached, do the following:
a. Get the next input token (constant, variable, arithmetic operator, left parenthesis, right parenthesis) in the infix expression.
b. If token is
i. a left parenthesis: Push it onto the stack.
ii. a right parenthesis: Pop and display stack elements until a left parenthesis is encountered, but do not display it. (It is an error if the stack becomes empty with no left parenthesis found.)
iii. an operator: If the stack is empty or token has a higher priority than the top stack element, push token onto the stack.
Otherwise, pop and display the top stack element: then repeat the comparison of token with the new top stack item.
Note: A left parenthesis in the stack is assumed to have a lower priority than that of operators
iv. an operand: Display it.
3. When the end of the infix expression is reached, pop and display stack items until the stack is empty.

btech 0 Light Poster

Well it does not output numbers since you dont print them (obviously) currently whenever a number is encountered the switch statement will fall through to the output stackopt statement producing the last encountered stackop instead of the current number...

so how can i fix this?

btech 0 Light Poster

This is a homework assignment and since we have never used yacc and bison I do not think I should do that for this assignment. I do thank you for your response though. What I need is to figure out why my alpha characters are not being outputed.

btech 0 Light Poster

The code below compiles but produces the wrong output. The code is supposed to convert an infix string to postfix. the current output is only the arithmetic operator, unless there are parenthesis then it will only show the right parenthesis. I have been woking on this for hours and am getting nowhere. Please help.

#ifndef H_stackType
#define H_stackType

#include <iostream>
#include <cassert>

using namespace std;

template<class Type>
class stackType
{
public:
	void initializeStack();
	bool isEmptyStack();
	bool isFullStack();
	void push(const Type& newItem);
  	Type top();
	void pop();
	stackType(int stackSize);
	~stackType();

private:
	int maxStackSize;
	int stackTop;
	Type *list;

};

template<class Type>
void stackType<Type>::initializeStack()
{
	stackTop = 0;
}

template<class Type>
bool stackType<Type>::isEmptyStack()
{
	return(stackTop == 0);
}

template<class Type>
bool stackType<Type>::isFullStack()
{
	return(stackTop == maxStackSize);
}

template<class Type>
void stackType<Type>::push(const Type& newItem)
{
 if(!isFullStack())
    {
		list[stackTop] = newItem;
		stackTop++;
    }
    else
		cerr<<"Cannot add to a full stack." << endl;
}

template<class Type>
Type stackType<Type>::top()
{
  assert(stackTop != 0);
  return list[stackTop - 1];
}

template<class Type>
void stackType<Type>::pop()
{
  if(!isEmptyStack())
	   stackTop--;
 	else
	   cerr<<"Cannot remove from an empty stack."<<endl;
}

template<class Type>
stackType<Type>::stackType(int stackSize) 
{
	if(stackSize <= 0)
	{
		cerr<<"Size of the array to hold the stack must "
			<<"be positive."<<endl;
		cerr<<"Creating an array of size 50."<<endl;

		maxStackSize = 50;
	}
	else
		maxStackSize = stackSize;

	stackTop = 0;	
	list = new Type[maxStackSize];
	assert(list != NULL);
}

template<class Type>
stackType<Type>::~stackType()
{
   delete [] list;
}

#endif

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

using namespace std;

string rpn(string infix);

int main()
{
  string infix;
  
  cout << …
btech 0 Light Poster

made the corrections but am still receiving the same error messages

btech 0 Light Poster

alright I simplified my code just to get it to compile however now I get only 2 errors and i do not know why

error LNK2020: unresolved token (0A00001B) stackType<char>.__dtor

fatal error LNK1120: 1 unresolved externals

can you please look at my code and tell me what I am doing wrong?

#ifndef H_stackType
#define H_stackType

template<class Type>
class stackType
{
public:
	void initializeStack();
	bool isEmptyStack();
	void push(const Type& newItem);
  	Type top();
	void pop();
	stackType(int stackSize = 50);
	~stackType();

private:
	int maxStackSize;
	int stackTop;
	Type *list;

};

#endif

#include "stackType.h"
#include <iostream>

using namespace std;

template<class Type>
void stackType<Type>::initializeStack()
{
	stackTop = 0;
}

template<class Type>
bool stackType<Type>::isEmptyStack()
{
	return(stackTop == 0);
}

template<class Type>
void stackType<Type>::push(const Type& newItem)
{
  if(!isFullStack())
    {
		list[stackTop] = newItem;
		stackTop++;
    }
    else
		cerr<<"Cannot add to a full stack."<<endl;
}

template<class Type>
Type stackType<Type>::top()
{
  assert(stackTop != 0);
  return list[stackTop - 1];
}

template<class Type>
void stackType<Type>::pop()
{
  if(!isEmptyStack())
	   stackTop--;
 	else
	   cerr<<"Cannot remove from an empty stack."<<endl;
}

template<class Type>
stackType<Type>::stackType(int stackSize) 
{
	if(stackSize <= 0)
	{
		cerr<<"Size of the array to hold the stack must "
			<<"be positive."<<endl;
		cerr<<"Creating an array of size 50."<<endl;

		maxStackSize = 50;
	}
	else
		maxStackSize = stackSize;

	stackTop = 0;	
	list = new Type[maxStackSize];
	assert(list != NULL);
}

template<class Type>
stackType<Type>::~stackType()
{
   delete [] list;
}

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

using namespace std;

string rpn(string infix);


int main()
{
  string infix;
  
  cout << "NOTE: Enter ! for infix expression to exit." << endl;
  for …
btech 0 Light Poster

"use array brackets" how would i do that? as i said before i am new to c++ and my book does not provide the help i need

btech 0 Light Poster

great that worked and taken care of the prvious errors however now i have 53 new errors.

error C2440: '=' : cannot convert from 'std::string' to 'char'
error C2664: 'stackType<Type>::push' : cannot convert parameter 1 from 'std::allocator<_Ty>::value_type' to 'const std::string &'
        with
        [
            Type=std::string
        ]
        and
        [
            _Ty=char
        ]
error C2676: binary '==' : 'std::string' does not define this operator or a conversion to a type acceptable to the predefined operator
error C2784: 'bool std::operator ==(const _Elem *,const std::basic_string<_Elem,_Traits,_Alloc> &)' : could not deduce template argument for 'const T1 *' from 'std::string'

do you know what these errors mean?

btech 0 Light Poster

You're using stack in RPN() as if it was a global variable, when in fact it is local to main().

im not sure i know what you mean. i am new to c++ can you elaborate.

btech 0 Light Poster

I cannot figure out these errors can someone please help

error C2065: 'stack' : undeclared identifier
error C2228: left of '.isEmptyStack' must have class/struct/union type
error C2228: left of '.pop' must have class/struct/union type
error C2228: left of '.push' must have class/struct/union type
error C2228: left of '.top' must have class/struct/union type
error C3861: 'stack': identifier not found, even with argument-dependent lookup

here is my code

#include <iostream>
using namespace std;

#ifndef H_stackType
#define H_stackType

template<class Type>
class stackType
{
public:
	const stackType<Type>& operator=(const stackType<Type>&);
	void initializeStack();
	bool isEmptyStack();
	bool isFullStack();
	void push(const Type& newItem);
  	Type top();
	void pop();
	stackType(int stackSize = 100);
	~stackType();

private:
	int maxStackSize;
	int stackTop;
	Type *list;

};

#endif

#include "stackType.h"
#include <iostream>

using namespace std;

template<class Type>
void stackType<Type>::initializeStack()
{
	stackTop = 0;
}

template<class Type>
bool stackType<Type>::isEmptyStack()
{
	return(stackTop == 0);
}

template<class Type>
bool stackType<Type>::isFullStack()
{
	return(stackTop == maxStackSize);
}

template<class Type>
void stackType<Type>::push(const Type& newItem)
{
  if (stackTop < stackSize - 1)
  {
    ++stackTop;
    list[stackTop] = newItem;
  }
  else
    cerr<<"Cannot add to a full stack."<<endl;
}

template<class Type>
Type stackType<Type>::top()
{
  assert(stackTop != 0);
  return list[stackTop - 1];
}

template<class Type>
void stackType<Type>::pop()
{
  if (stackTop >= 0)
    stackTop--;
  else
   cerr<<"Cannot remove from an empty stack."<<endl;
}

template<class Type>
stackType<Type>::stackType(int stackSize) 
{
	if(stackSize <= 0)
	{
		cerr<<"Size of the array to hold the stack must "
			<<"be positive."<<endl;
		cerr<<"Creating an array of size 100."<<endl;

		maxStackSize = 100;
	}
	else
		maxStackSize = stackSize;

	stackTop = 0;	
	list = new Type[maxStackSize];
	assert(list …
btech 0 Light Poster

Does this function look ok?

template<class Type>
void doublyLinkedList<Type>::copyList(const doublyLinkedList<Type>& otherList)
{
	nodeType<Type> *newNode;
	nodeType<Type> *current;

   if(first != NULL)
	  destroy();

   if(otherList.first == NULL)
   {
		first = NULL;
		last = NULL;
 		count = 0;
   }
   else
   {
		current = otherList.first; 
									
		count = otherList.count;

			
		first = new nodeType<Type>; 

 		assert(first != NULL);

		first->info = current->info;
		first->next = NULL; 
		
		last = first; 
        
		current = current->next;   
        
		while(current != NULL)
		{
			newNode = new nodeType<Type>;

			assert(newNode!= NULL);

			newNode->info = current->info;
			newNode->next = NULL;  
           
			last->next = newNode;
			last = newNode; 
			
			current = current->next;
		}
	} 
}
btech 0 Light Poster

My program compiles with no errors but when I run the program it asks "Enter the number to be deleted:" if I enter any number other than the first number listed the program crashes with the following error:

"An unhandled exception of type 'System.NullReferenceException' occurred in doublyLinkedList.exe

Additional information: Object reference not set to an instance of an object."

#ifndef H_doublyLinkedList
#define H_doublyLinkedList

#include <iostream>
#include <cassert>

using namespace std;

template <class Type>
struct  nodeType
{  
      Type info;
	  nodeType<Type> *next;
      nodeType<Type> *back;  
};

template <class Type>
class doublyLinkedList
{
    friend ostream& operator<<(ostream&, 
                           const doublyLinkedList<Type>&);
     
public:
    const doublyLinkedList<Type>& operator=
                           (const doublyLinkedList<Type> &);
    void initializeList();
    bool isEmptyList();
    void destroy();
	void printList() const;
    void reversePrint();
    int length();
    Type front();
    Type back();
    bool search(const Type& searchItem);
    void insertNode(const Type& insertItem);
    void deleteNode(const Type& deleteItem);
    doublyLinkedList(); 
    doublyLinkedList(const doublyLinkedList<Type>& otherList); 
    ~doublyLinkedList(); 
    
protected:
    int count;
	nodeType<Type> *first; 
    nodeType<Type> *last; 

private:
    void copyList(const doublyLinkedList<Type>& otherList); 
 };


template<class Type>
doublyLinkedList<Type>::doublyLinkedList()
{
	first= NULL;
	last = NULL;
	count = 0;
}

template<class Type>
bool doublyLinkedList<Type>::isEmptyList()
{
    return(first == NULL);
}

template<class Type>
void doublyLinkedList<Type>::destroy()
{ 
	nodeType<Type>  *temp; 
	
	while(first != NULL)
	{
		temp = first;
		first = first->next;
		delete temp;
	}

	last = NULL;
	count = 0;
}

template<class Type>
void doublyLinkedList<Type>::initializeList()
{
	destroy();
}

template<class Type>
int doublyLinkedList<Type>::length()
{
	return count;
}

template<class Type>
ostream& operator<<(ostream& osObject, 
					const doublyLinkedList<Type>& list)
{
    nodeType<Type> *current; 

	current = list.first;  

	while(current != NULL)
	{
	   cout<<current->info<<"  ";  
	   current = current->next;
	}

	return osObject;
}

template<class Type>
void doublyLinkedList<Type>::printList() const
{
    nodeType<Type> *current; …
btech 0 Light Poster

Your program compiles and links without error using VC++ 6.0 compiler, just like WolfPack said it would. I tried the same thing with Visual Studio 2003 and got the same error that you did, but unfortunately I havn't been able to figure out the problem either.

I ran the program through my compiler again commenting out lines to see what is causing the error. Turns out the program compiles if I comment out the cout << lines The weird thing is the .h (header file) was supplied to me with the exception of the last four functions. I am really confused now. Could I have written one of the last four functions wrong and that is causing errors in the << operator overload?

The functions I wrote are "copyList", constructor with parameters, = operator overload, and the destructor. Could you verify that those functions are correct? As the error might be originating from one of those functions.

btech 0 Light Poster

read those error messages again. The compiler (really the linker) is saying that one or more functions are missing. And it tells you the name of them.

Here is the error I am getting. As I said I do not see an error about a missing function. But honestly I do not understand how to read the error messages.

doublyLinkedList error LNK2001: unresolved external symbol "class std::basic_ostream<char,struct std::char_traits<char> > & __cdecl operator<<(class std::basic_ostream<char,struct std::char_traits<char> > &,class doublyLinkedList<int> const &)" (??6@$$FYAAAV?$basic_ostream@DU?$char_traits@D@std@@@std@@AAV01@ABV?$doublyLinkedList@H@@@Z)
btech 0 Light Poster

what function(s) did the compiler say was missing? Look at your code and see if you coded them. If they are in a library somewhare did you include the library?

The compiler did not specify that a function was missing. If I had to guess I would say the error is coming from the copyList function. It looks fine to me but once I added it the errors began.

btech 0 Light Poster

The assignment I am working on is to create a doubly linked list. This is what I have thus far. However when I compile I get 2 errors: LNK2001 unresolved external symbol and LNK1120 unresolved externals. Was hoping someone could look over my code and help me with these errors.

#ifndef H_doublyLinkedList
#define H_doublyLinkedList

#include <iostream>
#include <cassert>

using namespace std;

template <class Type>
struct  nodeType
{  
      Type info;
	  nodeType<Type> *next;
      nodeType<Type> *back;  
};

template <class Type>
class doublyLinkedList
{
    friend ostream& operator<<(ostream&, 
                           const doublyLinkedList<Type>&);
     
public:
    const doublyLinkedList<Type>& operator=
                           (const doublyLinkedList<Type> &);
    void initializeList();
    bool isEmptyList();
    void destroy();
    void reversePrint();
    int length();
    Type front();
    Type back();
    bool search(const Type& searchItem);
    void insertNode(const Type& insertItem);
    void deleteNode(const Type& deleteItem);
    doublyLinkedList(); 
    doublyLinkedList(const doublyLinkedList<Type>& otherList); 
    ~doublyLinkedList(); 
    
protected:
    int count;
	nodeType<Type> *first; 
    nodeType<Type> *last; 

private:
    void copyList(const doublyLinkedList<Type>& otherList); 
 };


template<class Type>
doublyLinkedList<Type>::doublyLinkedList()
{
	first= NULL;
	last = NULL;
	count = 0;
}

template<class Type>
bool doublyLinkedList<Type>::isEmptyList()
{
    return(first == NULL);
}

template<class Type>
void doublyLinkedList<Type>::destroy()
{ 
	nodeType<Type>  *temp; 
	
	while(first != NULL)
	{
		temp = first;
		first = first->next;
		delete temp;
	}

	last = NULL;
	count = 0;
}

template<class Type>
void doublyLinkedList<Type>::initializeList()
{
	destroy();
}

template<class Type>
int doublyLinkedList<Type>::length()
{
	return count;
}

template<class Type>
ostream& operator<<(ostream& osObject, 
					const doublyLinkedList<Type>& list)
{
    nodeType<Type> *current; 

	current = list.first;  

	while(current != NULL)
	{
	   cout<<current->info<<"  ";  
	   current = current->next;
	}

	return osObject;
}

template<class Type>
void doublyLinkedList<Type>::reversePrint()
{
      nodeType<Type> *current; 

	  current = last;  

      while(current != NULL)
      {
	      cout<<current->info<<"  ";  
	      current = current->back;
      }
}

template<class …
btech 0 Light Poster

Thank you this was exactly what I was looking for

btech 0 Light Poster

I want to make a option on my toolbar a "drop down" element. I want the user to be able to mouse over links and be able to select their link from a scroll out menu. below is my navbar. could someone please help.

<!-- Site navigation menu -->
<ul class="navbar">
<br><br>
<h2><b>Site Navigation</h2>
<hr width="70" align="center">
<center>
<li><a href="index.html">Home</a>
<li><a href="activities.html">Activities</a>
<li><a href="bulletin.html">Bulletin</a>
<li><a href="churchLeaders.html">Church Leaders</a>
<li><a href="contact.html">Contact Us</a>
<li><a href=" ">Links</a><br />
</ul></center>

btech 0 Light Poster

I want to make a option on my toolbar a "drop down" element. I want the user to be able to mouse over links and be able to select their link from a scroll out menu. below is my navbar. could someone please help.

<!-- Site navigation menu -->
<ul class="navbar">
<br><br>
<h2><b>Site Navigation</h2>
<hr width="70" align="center">
<center>
<li><a href="index.html">Home</a>
<li><a href="activities.html">Activities</a>
<li><a href="bulletin.html">Bulletin</a>
<li><a href="churchLeaders.html">Church Leaders</a>
<li><a href="contact.html">Contact Us</a>
<li><a href=" ">Links</a><br />
</ul></center>

btech 0 Light Poster

Let me make sure I am clear. If i plan to host my own domain name all I need to do is:
1. purchase a domain name of my choosing
2. setup my server accordingly to host my site
3. setup an email server to host my mail

is this correct. or do i need to purchase email accounts as well. I was a little confused when i went to purchase my domain name and the site asked me first if i wanted my site to be hosted. then it asked if i would like to purchase email addresses? please someone clarify. it sounds like you would purchase email addresses if you were having them hosted as well but i cannot find anything on the web to confirm.

btech 0 Light Poster

now i am having a problem setting up the main in relation with the derived class. The errors are
newClockType.setTime does not take 1 argument
newClockType.getTime does not take 1 argument
see code below

#include <iostream>
#include "clockType.h"
#include "extClockType.h"

using namespace std;

int main()
{
    clockType myClock;
    clockType yourClock;
	
	extClockType newClockType;
	extClockType oldClockType;
	
	int hours;
    int minutes;
    int seconds;

    myClock.setTime(5, 4, 30);
    newClockType.setTime(8);
	
    cout << "myClock: ";
    myClock.printTime();
    newClockType.printTime();
    cout << endl;

    cout << "yourClock: ";
    yourClock.printTime();
    oldClockType.printTime();
    cout << endl;
      
    yourClock.setTime(5, 45, 16);
    oldClockType.setTime(7);

	cout << "After setting, yourClock: ";
    yourClock.printTime();
    oldClockType.printTime();
    cout << endl;
   
    if (myClock.equalTime(yourClock))
        cout << "Both times are equal."
             << endl;
    else
        cout << "The two times are not equal."
             << endl;

    cout << "Enter the hours, minutes, and "
         << "seconds: ";
    cin >> hours >> minutes >> seconds;
    cout << endl;

    myClock.setTime(hours, minutes, seconds);
    newClockType.setTime(t);
	
    cout << "New myClock: ";
    myClock.printTime();
    newClockType.printTime();
	cout << endl;
     
    myClock.incrementSeconds();

    cout << "After incrementing myClock by "
         << "one second, myClock: ";
    myClock.printTime();
    cout << endl;
    
    myClock.getTime(hours, minutes, seconds);
    newClockType.getTime(t);	
     
    cout << "hours = " << hours 
         << ", minutes = " << minutes
         << ", seconds = " << seconds << endl;


	return 0;
}
btech 0 Light Poster

i think my derived class is now correct

class extClockType: public clockType
{
  public:
	int getTimeZone();
	void setTimeZone(int t);
	void setTime(int hours, int minutes, int seconds, int t);
	void getTime(int& hours, int& minutes, int& seconds, int& t) const;
	void printTime() const;
	extClockType();
	extClockType(int hours, int minutes, int seconds, int t);
  private:
	int timeZone;
};


#include <iostream>
#include "clockType.h"
#include "extClockType.h"

using namespace std;



int extClockType::getTimeZone()
{
	return timeZone;
}

void extClockType::setTimeZone(int t)
{
	timeZone = t;
}

void extClockType::setTime(int hours, int minutes, int seconds, int t)
{
	clockType::setTime(hours, minutes, seconds);
	timeZone = t;
}

void extClockType::getTime(int& hours, int& minutes, int& seconds, int& t) const
{
	clockType::getTime(hours, minutes, seconds);
	t = timeZone;
}

void extClockType::printTime() const
{
	clockType::printTime();
	cout << "The timezone is: " << timeZone << endl;
	if(timeZone >= 0)
    cout << "+" << timeZone;
}

extClockType::extClockType() 
{
	timeZone = 0;	
}

extClockType::extClockType(int hours, int minutes, int seconds, int t): clockType(hours, minutes, seconds)
{
	if(timeZone > 12 || timeZone < -12)
    timeZone = 0;
  else
    timeZone = t;
}

now i am having a problem setting up the main in relation with the derived class. The errors are
newClockType.setTime does not take 1 argument
newClockType.getTime does not take 1 argument
see code below

#include <iostream>
#include "clockType.h"
#include "extClockType.h"

using namespace std;

int main()
{
    clockType myClock;
    clockType yourClock;
	
	extClockType newClockType;
	extClockType oldClockType;
	
	int hours;
    int minutes;
    int seconds;

    myClock.setTime(5, 4, 30);
    newClockType.setTime(8);
	
    cout << "myClock: ";
    myClock.printTime();
    newClockType.printTime();
    cout << endl;

    cout << "yourClock: …
btech 0 Light Poster

This is what I am confused about as well. I do not understand what will determine the time zone also what format the assignment is looking for GMT or eastern vs central vs western. I have posted all the information I was given to complete this assignment.

btech 0 Light Poster

oh sorry here it is

class clockType
{
public:
    void setTime(int hours, int minutes, int seconds);
    void getTime(int& hours, int& minutes, int& seconds);
    void printTime() const;
    void incrementSeconds();
    void incrementMinutes();
    void incrementHours();
    bool equalTime(const clockType& otherClock) const;
    clockType(int hours, int minutes, int seconds);
    clockType();

private:
    int hr;  
    int min; 
    int sec; 
};



#include <iostream>
#include "clockType.h"

using namespace std;

void clockType::setTime(int hours, int minutes, int seconds)
{
    if(0 <= hours && hours < 24)
        hr = hours;
    else 
        hr = 0;

    if(0 <= minutes && minutes < 60)
        min = minutes;
    else 
        min = 0;

    if(0 <= seconds && seconds < 60)
        sec = seconds;
    else 
        sec = 0;
}

void clockType::getTime(int& hours, int& minutes, int& seconds)
{
    hours = hr;
    minutes = min;
    seconds = sec;
}

void clockType::printTime() const
{
    if(hr < 10)
       cout<<"0";
    cout<<hr<<":";

    if(min < 10)
       cout<<"0";
    cout<<min<<":";

    if(sec < 10)
       cout<<"0";
    cout<<sec;
}

void clockType::incrementHours()
{
    hr++;
    if(hr > 23)
      hr = 0;
}

void clockType::incrementMinutes()
{
    min++;
    if(min > 59)
    {
       min = 0;
       incrementHours(); 
    }
}

void clockType::incrementSeconds()
{
    sec++;
    if(sec > 59)
    {
       sec = 0;
       incrementMinutes(); 
    }
}

bool clockType::equalTime(const clockType& otherClock) const
{
   return(hr == otherClock.hr 
        && min == otherClock.min 
          && sec == otherClock.sec);
}

clockType::clockType(int hours, int minutes, int seconds)
{
    setTime(hours, minutes, seconds);
}

clockType::clockType()  
{
    setTime(0, 0, 0);
}
btech 0 Light Poster

I am trying to write a program which will derive one class from another class by adding a data member to store the time zone. Below is what I have so far. However I am unsure on how to write the function to set the time zone. could someone please help?

class extClockType: public clockType
{
  public:
	int getTimeZone();
	void setTimeZone();
	void printTime() const;
	extClockType();
	extClockType(int hours, int minutes, int seconds, int t);
  private:
	int timeZone;
};

int extClockType::getTimeZone()
{
	return timeZone;
}

void extClockType::setTimeZone()
{

}

void extClockType::printTime() const
{
	clockType::printTime();
	cout << "The timezone is: " << timeZone << endl;
}

extClockType::extClockType() 
{
	timeZone = 0;	
}

extClockType::extClockType(int hours, int minutes, int seconds, int t): clockType(hours, minutes, seconds)
{
	timeZone = t;
}
btech 0 Light Poster

thank you, i was close just needed to add the function. you had given me a link for the second part of the question but i do not understand how to find the order of the function through the link. could you explain that please.

btech 0 Light Poster

this is what i have. the program compiles without error but is returning 0 as a value

int main()
{
int n;
int sum;

for (int i = 0; i <= n; i++)
sum = i*i + i;

cout << "the sum is: " << sum;
return 0;
}

btech 0 Light Poster

like this? or am i still way off?

int main()
{

int count=0;
    while (count<=n)
    {
        count = count + i^i
    }

return 0;
}
btech 0 Light Poster

could i get some help on getting started? i have no idea how to find the sum of the squares of all integers. would the following be right?

int main()
{
for (int i = 2; i <= n; i++)
sum = i + n;

return 0;
}

btech 0 Light Poster

the assignment i am working on ask to write a function that uses a loop to find the sum of the squares of all integers between 1 and n. then asks "what is the order of your functions?"

my question, which may be obvious is what is n? and what does is the second question looking for "what is the order of your function?". will someone please clarify for me as I am new to C++

Thank you in advance