Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8804439
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T01:36:21+00:00 2026-06-14T01:36:21+00:00

I am writing a program that is like boggle, but that has much less

  • 0

I am writing a program that is like boggle, but that has much less difficulty. My program program is meant to receive the number of Lines of Letters (all same amount of letters) and then receive on separate lines the Letters. Proceeded by the number of words I am going to guess and each line after words I am going to guess;
such as shown below:

5
SRENG
OLIOA
VISKE
THAOR
PDTAL
4
LORE
NOSE
ROILS
SAILORS

The output would be board obviously, but nothing special is needed for that and which words were found and which ones weren’t along with the direction of the words that succeded:

Such as:

LORE
"FOUND!"
"W, NE, E"

So now here is where it gets confusing for me. I have my main program which is called scramble.cc that includes all the code for solving the actually problem, while the other programs that I am using are pair.h, pair.cc, list.h, and list.cc (of course my compiler as well)
My pair code:

#include <iostream>
#include <cstdlib>
#ifndef PAIR
#define PAIR

using namespace std;

struct Pair{
 int r, c;
 Pair(size_t r1, size_t c1);
 Pair();
 void print(ostream & ostr)const;
 size_t get(size_t index);
};
ostream & operator<<(ostream & ostr, const Pair & p);
bool operator==(const Pair & p1, const Pair & p2);
bool operator!=(const Pair & p1, const Pair & p2);

#endif

pair.cc

#include <iostream>
#include <cstdlib>
#include "pair.h"
using namespace std;

Pair::Pair(size_t r1, size_t c1)
{
 r=r1;
 c=c1;
}

Pair::Pair()
{
r=c=0;
}

void Pair::print(ostream & ostr) const
{
 ostr << r << "," << c;
}

ostream & operator<<(ostream & ostr, const Pair & p)
{
 p.print(ostr)
 return ostr;
}

bool operator==(const Pair & p1, const Pair & p2)
{
 return p1.r == p2.r and p1.c == p2.c
}

bool operator!=(const Pair & p1, const Pair & p2)
{
 return not(p1==p2)
}

My List.h:

#include <cstdlib>
#include <iostream>
#include "pair.h"
using namespace std;
class List
{
 public:
  typedef Pair ElementType;
  typedef int ElementType //this is what I used before putting in pair.h/.cc

 List();
 ~List();
 List(const List & orig)
 void add(const ElementType & item, size_t index);
 void removeAt(size_t index);
 void remove(const ElementType & item)
 size_t find(const ElementType & item) const;
 ELementType get(size_t index) const;
 size_t getSize() const;
 void output(std::ostream & ostr) const;

private:
 struct Node{
  Node *prev;
  ELementType data;
  Node*next;
  Node();
  Node(Node *p, Node *n);
  Node(Node *p, const ElementType & d, Node *n);
};

void _setCurrentIndex(size_t index) const;

size_t size;
mutable size_t currentIndex;
Node *front;
Node *rear;
mutable Node *current;

};

My list.cc code:

#include <iostream>
#include <cassert>
#include <cstdlib>
#include "list.h"

using namespace std;

List::Node::Node()
{
 prev = next = NULL;
}

List:: List()
{
 front = new Node()
 rear = new Node()
 front->next = rear;
 rear->prev = front;

 currentIndex=0;
 current = front->next;
 size=0;
}

List::~List()
{
 _setCurrentIndex(0);
 while(current)
  {
   Node *temp = current;
   current = current -> next;
   delete temp;
  }
//not showing deep copy function b/c it isn't important for this program
void List::add(const ElementType & item, size_t index)
{
 assert(0<=index && index <= size);
 _setCurrentIndex(index);
 size++;

 Node *born = new Node;
 born->data = item;
 born->prev = current->prev;
 born->prev->next = current;
 born->prev = born;
 current = born;
}

void List::removeAt(size_t index)
{
 assert(0<=index<=getSize());
 _setCurrentIndex(index);

 Node *old = current;
 current->prev->next = current->next;
 current->next->prev = current->prev;
 delete old;
 size--;
}

void List::remove(const ElementType & item)
{
 for(size_t i=0; i<size; i++)
  {
  _setCurrentIndex(i);
   if(find(item)<getSize())
    {
     Node *tempOld = current;
     current->next->prev = current->prev;
     current->prev->next = current->next;
     current = current->next;

     delete tempOld;
     size--;
    }
  }
}

size_t List::find(const ElementType & item) const
{
 for(size_t i=0; i<size; i++)
  {
   _setCurrentIndex(i)
   if(get(i) == item)
    return get(i);
  }
 return getSize();
}

List::ElementType List::get(size_t index) const
{
 assert(0 <= index < size);
 _setCurrentIndex(index);
 assert(current->next != NULL);
 return current->data;
}

size_t List::getSize() const
{
 return size;
}

void List::output(std::ostream & ostr) const
{
 for(size_t i=0; i<size; i++) 
  {
  _setCurrentIndex(i);
  ostr << current->data << " ";
  }
 ostr << endl;
}

void List:: _setCurrentIndex(size_t index) const
{
 int x;
 if(currentIndex > index)
  x = currentIndex - index;
 else
  x = index-currentIndex;

 if(index < (sizez_t)x)
  {
  current = front->next;
  curentIndex=0;
  while(currentIndex != index)
   {
   current = current->next;
   currentIndex++;
   }
  }
 else if((size-index) < (size_t)x)
  {
   current = rear;
   currentIndex = size;
   while(currentIndex != index)
    {
     current = current->prev;
     currentIndex--;
    }
  }
 else
  {
   if(currentIndex > index)
    {
    while(currentIndex!=index)
     {
      current = current->prev;
      currentIndex--;
     }
    }
   else
    {
     while(currentIndex!=index)
      {
       current = current->next;
       currentIndex++;
      }
    }
  }
}

My scramble.cc:

#include <iostream>
#include <cstdlib>
#include "list.h"
#include "pair.h"
using namespace std;

List history;
Pair p1 = Pair(1,1);

int main()
{

}

My Makefile

scramble: scramble.o list.o pair.o
     g++ -o scramble scramble.o list.o pair.o
scramble.o: scramble.cc list.h pair.h
     g++ -c scramble.cc
list.o: list.cc list.h pair.h
     g++ -c list.cc
pair.o pair.cc pair.h
     g++ -c pair.cc

So that is my code, I had to write that out all by hand b/c the program I use doesn’t do copy and paste so please forgive me if there are small errors(such as forgetting ; or misspelling).

So my biggest problem is when I try to make Pairs and put them into a List it freaks out by giving me errors of being unable to convert Pair to size_t in functions such as Find. There are also tons of undefined references List::List(), List::~List(), Pair::Pair(unsigned long, unsigned long), List::add(Pair const&, unsigned long), List::getSize() const, List::removeAt(unsigned long).

So can anyone please help me out here on what I need to do to my List class and pair? I goal is to store Pairs in the List and be able to remove them that is my main objective for this.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T01:36:22+00:00Added an answer on June 14, 2026 at 1:36 am

    As a piece of advice, you should include significantly less code in future posts. You are more likely to get help if you’ve narrowed the problem down to a specific piece of code. Additionally, exact error messages are very helpful.

    As for the problem you describe,

    it freaks out by giving me errors of being unable to convert Pair to
    size_t in functions such as Find

    Your problem is with this code :

    size_t List::find(const ElementType & item) const
    {
       ...
       if(get(i) == item)
        return get(i); 
       ...
    }
    
    List::ElementType List::get(size_t index) const
    

    Note that List::get returns a List::ElementType and List::find returns a size_t. Therefore, the statement return get(i); is attempting to return a List::ElementType in a function that expects a size_t to be returned. You most likely want that to be return i; instead.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am writing a program that is sort of like boggle, but I am
Unfortunately I don't know much networks. I am writing a program that has two
I'm writing a simple program that has a couple of functions that look like
I'm writing a C program that needs good error handling. The code likes like
HI I'm writing a program that acts as a server and has the ability
I'm writing a program that has an NSView embedded in an NSScrollView which user
I am writing a program that could very much use __sync_fetch_and_add . Unfortunately my
I am writing a program that and like to implement data verification system. It
I 'm writing a little program that implements pipes like they work in the
I'm writing a program that creates a Word document with sensitive information. I'd like

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.