C++ 为什么使用运算符<;比较两个数组元素时会出现错误;,即使我已经使操作符超载<;?

C++ 为什么使用运算符<;比较两个数组元素时会出现错误;,即使我已经使操作符超载<;?,c++,syntax-error,C++,Syntax Error,-不断发生的错误: “[”标记之前应为主表达式 “[”标记之前应为主表达式 void selectionSort(Blog Blog[],int numBlogs) { 博客温度; int minIndex=0; 对于(int i=0;i您的比较是与类型Blog进行比较,而不是与对象Blog(注意大小写差异)。与Blog[j]进行比较是一个语法错误,因为这是类型而不是实例 这应该是: if(blog[j]

-不断发生的错误:

  • “[”标记之前应为主表达式
  • “[”标记之前应为主表达式
void selectionSort(Blog Blog[],int numBlogs)
{
博客温度;
int minIndex=0;

对于(int i=0;i您的比较是与类型
Blog
进行比较,而不是与对象
Blog
(注意大小写差异)。与
Blog[j]
进行比较是一个语法错误,因为这是类型而不是实例

这应该是:

if(blog[j]
请提供一个。您不是在比较两个数组。您是在比较两个数组元素,或者尝试比较。我将“Blog”更改为“Blog”,现在出现以下错误:[错误]与不匹配'operator@HaydenHibbett这意味着
Blog
类型没有
操作符
void selectionSort(Blog blog[], int numBlogs)
{
    Blog temp;
    int minIndex=0;
    for (int i=0; i<numBlogs-1; i++)
    {
        minIndex = i;
        for (int j=i+1; j<numBlogs; j++)
        if (Blog[j] < Blog[minIndex]) //this is where the error occurs
                minIndex=j;     //swap positions i and minIndex
        temp = blog[i];
        blog[i] = blog[minIndex];
        blog[minIndex] = temp;
        displayBlogs(blog, numBlogs);   
    }
}