Visual Studio C++ bool std:: operator == error

Hello,
I am currently programing in Visual C++. I am a C++ programmer, but I am not used to using visual Studios; code that works in PuTTy does not always work here.

For instance, in my .cpp file I have these two errors:

 error C2784: 'bool std::operator ==(const     std::basic_string<_Elem,_Traits,_Alloc> &,const _Elem *)' : could not deduce template argument for 'const _Elem *' from 'TableColumnsItemType'	c:\Users\A091250\HSQA\HSQA Applications\New_ForIneteractiveReports_Klinesmith\Report View Interface C++ version\Report View Interface C++ version\TableColumnsSortedLinkedList.cpp	72	Report View Interface C++ version


The second error is the same, except for '!=' and not '=='



1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
//TableColumsSortedLinkedList.cpp
#include <string>
#include "TableColumnsSortedLinkedList.h"

void ColumnsSortedType::DeleteItem(TableColumnsItemType item) 
{
  NodeType* location = listData;
  NodeType* tempLocation;

  string dataName;
  dataName = item.ReturnDataName();

  // Locate node to be deleted.
  if (dataName == (listData->info)) //Error is here!
  {
    tempLocation = location;
    listData = listData->next;          // Delete first node.
  }
  else
  {
    while (dataName != ((location->next)->info)) //And error here
      location = location->next;

    tempLocation = location->next;
    location->next = (location->next)->next;
  }
  delete tempLocation;
  length--;
}


// TableColumnsSortedLinkedList.h
#include "TableColumnsItemType.h"

#include <iostream>
#include <fstream>
//This is a class for a sorted, linked list. This data will be used in the listbox of form1. Makes used of TableColumsItemType.h

#include <string>
using namespace std;

struct NodeType
{
	TableColumnsItemType info; //This part of node holds data
	NodeType* next; //This part of node is a pointer to the next item in the list. Will use info-> next syntax to reference next item.
};

class ColumnsSortedType
{
	NodeType *listData;
	int length;
	NodeType *currentPos;


//Function prototypes.....
};


Is it my pointers? I assume that there is a issue with comparing the datatypes, because I do have #include<string>


> if (dataName == (listData->info)) //Error is here!

dataName is an object of type std::string;
listData->info is an object of type TableColumnsItemType.

Do you have a user-defined == operator between the two?
Or an implicit conversion from TableColumnsItemType to std::string?
Last edited on
What is TableColumnsItemType?
[code[u]]//TableColumnsItemType[/u]

#pragma once
#include <string>
using namespace std;

class TableColumnsItemType
{

string visibleName;
string dataName; //dataName is string

public:

string ReturnVisibleName();


string ReturnDataName();

};
[/code]

Also, please note that my code has dataName declared as a local string variable, set to item.dataName for this purpose, and this appears to throw no error...?
Oh! I believe it's because I have have dataName pointed to; it is still pointing to TWO class memebers, not one. I forgot there were two.
Let me try to fix it, and see if that solves the issue.
Topic archived. No new replies allowed.