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

  • Home
  • SEARCH
  • 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 6845295
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T00:28:59+00:00 2026-05-27T00:28:59+00:00

i am working on a program that reads in a text file that the

  • 0

i am working on a program that reads in a text file that the user inputs, creates a text file that the user inputs, names the text file that the user wants, and then sorts the text file sorting words above the user entered in threshold and displays the words and how many times it was found to the output file the user specify’s. i have most of the code finished but im getting a compiler error heres the sample output, error and code

sample output

Enter name of input command file; press return.
history.in
Enter name of output file; press return.
history.out
Enter name of test run; press return.
sample
Enter the minimum size word to be considered.
5
Sample results (found in user specified output file):
sample
abacus 4
abstract 1
adding 1
addition 2
advances 1
after 3

where the word is the word found in the text file, and the number next to it is how many times it was found.

The compiler errors are:

C:\Users\kevin jack\Desktop\prog-4>g++ -o try main.cpp
main.cpp:(.text+0x329) undefined reference to `StrType::PrintToFile(bool, std::basic_ofstream<char, std::char_traits<char> >&)'
:main.cpp:(.text+0x608): undefined reference to `StrType::GetStringFile(bool, InType, std::basic_ifstream<char, std::char_traits<char> >&)'
main.cpp:(.text+0x639): undefined reference to `StrType::LenghtIs()'
main.cpp:(.text+0x6d8): undefined reference to `StrType::GetStringFile(bool, InType, std::basic_ifstream<char, std::char_traits<char> >&)'
collect2: ld returned 1 exit status

i have no idea what this means if anyone knows please inform me here is my code

main.cpp

//main.cpp
#include <fstream>
#include "StrType.h"
#include <cstddef>
#include <iostream>
#include <string>
using namespace std;

struct WordType
{
       public:
              StrType word;       
              int count;


};


struct TreeNode
{
       WordType info;
       TreeNode* left;
       TreeNode* right;

};

class ListType
{
      public:
             ListType();
             void InsertOrIncrement (StrType string);
             void Print(std::ofstream&) const;
      private:
              TreeNode* root;
};


ListType::ListType()
{
     root=NULL;
}

void Process(TreeNode*& tree, StrType s)
{

     if(tree == NULL)
     {
         tree = new TreeNode;
         tree->info.word = s;
         tree->info.count = 1;
         tree->left = NULL;
         tree->right = NULL;
     }

     else if (tree->info.word == s)
         tree->info.count++;
     else if (s < tree->info.word)
         Process(tree->left, s);
     else 
         Process(tree->right, s);
}

void ListType::InsertOrIncrement(StrType s)
{
     Process(root, s);
}

void Print (TreeNode* tree, std::ofstream& outFile)
 {

      if (tree!= NULL)
      {
          Print(tree->left, outFile);
          tree->info.word.PrintToFile(true, outFile);
          outFile <<" "<< tree->info.count;
          Print(tree->right, outFile);
      }
 }

 void ListType::Print(std::ofstream& outFile) const
 {
      ::Print(root, outFile);
 }


int main()
{
    using namespace std;
    ListType list;
    string inFileName;
    string outFileName;
    string outputLabel;
    ifstream inFile;
    ofstream outFile;
    StrType string;
    int minimumLenght;

    cout<<"enter in imput file name."<<endl;
    cin>>inFileName;
    inFile.open(inFileName.c_str());

    cout<<"enter name of output file."<<endl;
    cin>>outFileName;
    outFile.open(outFileName.c_str());

    cout<<"enter name of test run."<<endl;
    cin>>outputLabel;
    outFile<< outputLabel << endl;

    cout<<"enter the min word size."<<endl;
    cin>>minimumLenght;

    string.GetStringFile(true, ALPHA_NUM, inFile);
    while(inFile)
    {

         if(string.LenghtIs() >= minimumLenght)
            list.InsertOrIncrement(string);
         string.GetStringFile(true, ALPHA_NUM, inFile);
    }

    list.Print(outFile);
    outFile.close();
    inFile.close();
    return 0;
}

StrType.h

//StrType.h
#include <fstream>
#include <iostream>

const int MAX_CHARS=100;
enum InType{ALPHA_NUM, ALPHA, NON_WHITE, NOT_NEW};

class StrType
{
      public:
             void MakeEmpty();
            void GetString(bool skip, InType charsAllowed);
             void GetStringFile(bool skip, InType charsAllowed,
                std::ifstream& inFile);
             void PrintToScreen(bool newLine);
             void PrintToFile(bool newLine, std::ofstream& outFile);
             int LenghtIs();
             void CopyString(StrType& newString);
              bool operator==(const StrType& other) const;  
              bool operator<(const StrType& other) const;




      private:
              char letters[MAX_CHARS + 1];

};
bool StrType::operator==(const StrType& other) const  
{  
    return (strcmp(letters, other.letters) == 0);  
}  

bool StrType::operator<(const StrType& other) const  
{  
    return (strcmp(letters, other.letters) < 0);  
}  

void StrType::MakeEmpty()
{
     letters[0] ='\0';
}

what i was trying to overload the == and > operator. i am stating it in class StrType and defining it just below it but im not sure if im defining it correctly or even in the right spot! any help would be greatly appreciated

  • 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-05-27T00:29:00+00:00Added an answer on May 27, 2026 at 12:29 am

    notMine.cpp

     //StrType.h
    #include <fstream>
    #include <iostream>
    
    const int MAX_CHARS=100;
    enum InType{ALPHA_NUM, ALPHA, NON_WHITE, NOT_NEW};
    
    class StrType
    {
          public:
                 void MakeEmpty();
                void GetString(bool skip, InType charsAllowed)
                {
                }
                void GetStringFile(bool skip, InType charsAllowed, std::ifstream& inFile)
                {
                }
                void PrintToScreen(bool newLine)
                {
                }
                void PrintToFile(bool newLine, std::ofstream& outFile)
                {
                }
                int LenghtIs()
                {
                         return 0; 
                }
                void CopyString(StrType& newString)
                {
                }
                bool operator==(const StrType& other) const
                {  
                         return (strcmp(letters, other.letters) == 0);  
                }  
                bool operator<(const StrType& other) const
                {  
                        return (strcmp(letters, other.letters) < 0);  
                }  
    
    
    
    
          private:
                  char letters[MAX_CHARS + 1];
    
    };
    
    
    void StrType::MakeEmpty()
    {
         letters[0] ='\0';
    }
    

    myOwnSomething.h

    #include <stdio.h> 
    #include <fstream>
    #include <cstddef>
    #include <iostream>
    #include <string>
    #include "myOwnSomething.h" 
    using namespace std;
    
    struct WordType
    {
           public:
           StrType word;       
           int count;
    
    
    };
    
    
    struct TreeNode
    {
           WordType info;
           TreeNode* left;
           TreeNode* right;
    
    };
    
    class ListType
    {
          public:
                 ListType();
                 void InsertOrIncrement (StrType string);
                 void Print(std::ofstream&) const;
          private:
                  TreeNode* root;
    };
    
    
    ListType::ListType()
    {
         root=NULL;
    }
    
    void Process(TreeNode*& tree, StrType s)
    {
    
         if(tree == NULL)
         {
             tree = new TreeNode;
             tree->info.word = s;
             tree->info.count = 1;
             tree->left = NULL;
             tree->right = NULL;
         }
    
         else if (tree->info.word == s)
             tree->info.count++;
         else if (s < tree->info.word)
             Process(tree->left, s);
         else 
             Process(tree->right, s);
    }
    
    void ListType::InsertOrIncrement(StrType s)
    {
         Process(root, s);
    }
    
    void Print (TreeNode* tree, std::ofstream& outFile)
     {
    
          if (tree!= NULL)
          {
              Print(tree->left, outFile);
              tree->info.word.PrintToFile(true, outFile);
              outFile <<" "<< tree->info.count;
              Print(tree->right, outFile);
          }
     }
    
     void ListType::Print(std::ofstream& outFile) const
     {
          ::Print(root, outFile);
     }
    
    
    int main()
    {
        using namespace std;
        ListType list;
        string inFileName;
        string outFileName;
        string outputLabel;
        ifstream inFile;
        ofstream outFile;
        StrType string;
        int minimumLenght;
    
        cout<<"enter in imput file name."<<endl;
        cin>>inFileName;
        inFile.open(inFileName.c_str());
    
        cout<<"enter name of output file."<<endl;
        cin>>outFileName;
        outFile.open(outFileName.c_str());
    
        cout<<"enter name of test run."<<endl;
        cin>>outputLabel;
        outFile<< outputLabel << endl;
    
        cout<<"enter the min word size."<<endl;
        cin>>minimumLenght;
    
        string.GetStringFile(true, ALPHA_NUM, inFile);
        while(inFile)
        {
    
             if(string.LenghtIs() >= minimumLenght)
                list.InsertOrIncrement(string);
             string.GetStringFile(true, ALPHA_NUM, inFile);
        }
    
        list.Print(outFile);
        outFile.close();
        inFile.close();
        return 0;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am working on a program that reads a text file and stores parts
I am working on a program that reads in from a serial port, then
I have a program that inputs text and sorts through it using a number
I'm working on a program that reads in users input as a string, which
I'm working on a program that searches entire drives for a given file. At
I am working on a program that encodes a file based on a supplied
I'm working on a program that asks for input, then calculates and posts the
I'm currently working on a program that has many of those the user SHOULD
I have some text configuration file that need to be read by my program.
I am working on a program that needs to create a multiple temporary folders

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.