Ошибка компилятора c3861

Search code, repositories, users, issues, pull requests…

Provide feedback

Saved searches

Use saved searches to filter your results more quickly

Sign up

You need to move calc_grade above grade so that it knows it exists. Or declare it above like this.

double calc_grade(double midterm, double final, std::vector<double>& homework);

Your grade method is marked const, so it may not change your class. But you are calling calc_grade which does not take a const vector therefor it could change the class member you are handing it. You can make it take a const vector to solve this. I would make that method const as well to keep things consistent.

One possible fix:

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>

//////////////////////////////////////////////////////////
//////////////////////////CORE CLASS//////////////////////
//////////////////////////////////////////////////////////
class Core {
public:
    Core() : midterm(0), final(0) { }
    Core(std::istream& is) { read(is); }

    std::string name() const;

    virtual std::istream& read(std::istream&);
    virtual double grade() const;
protected:
    std::istream& read_common(std::istream&);
    std::istream& read_hw(std::istream&, std::vector<double>&);
    double midterm, final;
    std::vector<double> homework;
private:    
    std::string n;  
};

std::string Core::name() const { return n; }


double calc_grade(double midterm, double final, const std::vector<double>& homework)
{
    double result = 0.0;
    for (std::vector<double>::const_iterator i = homework.begin(); i != homework.end(); ++i)
        result += *i;

    return midterm*0.4 + final*0.4 + (result / homework.size())*0.2;
}


double Core::grade() const
{
    return calc_grade(midterm, final, homework);
}

std::istream& Core::read_common(std::istream& in)
{
    in >> n >> midterm >> final;
    return in;
}

std::istream& Core::read(std::istream& in)
{
    read_common(in);
    read_hw(in, homework);
    return in;
}

std::istream& Core::read_hw(std::istream& in, std::vector<double>& homework)
{
    double input;
    while (in >> input)
        homework.push_back(input);

    return in;
}

//////////////////////////////////////////////////////////
//////////////////////////GRAD CLASS//////////////////////
//////////////////////////////////////////////////////////
class Grad : public Core {
public:
    Grad() : thesis(0) { }
    Grad(std::istream& is) { read(is); }

    double grade() const;
    std::istream& read(std::istream&);
private:
    double thesis;
};

std::istream& Grad::read(std::istream& in)
{
    read_common(in);
    in >> thesis;
    read_hw(in, homework);
    return in;
}

double Grad::grade() const
{
    return std::min(Core::grade(), thesis);
}

//////////////////////////////////////////////////////////
//////////////////////MISCELLANEOUS///////////////////////
//////////////////////////////////////////////////////////
bool compare_grades(const Core& c1, const Core& c2)
{
    return c1.grade() < c2.grade();
}

bool compare_Core_ptrs(const Core* cp1, const Core* cp2)
{
    return compare_grades(*cp1, *cp2);
}

using namespace std;

int main()
{
    vector<Core*> students;
    Core* record;
    char ch;
    string::size_type maxlen = 0;

    while (cin >> ch)
    {
        if (ch == 'U')
            record = new Core;
        else
            record = new Grad;
        record->read(cin);
        maxlen = max(maxlen, record->name().size());
        students.push_back(record);
    }

    sort(students.begin(), students.end(), compare_Core_ptrs);

    for (vector<Core*>::size_type i = 0; i != students.size(); ++i)
    {
        cout << students[i]->name() << string(maxlen + 1 - students[i]->name().size(), ' ');
        try
        {
            double final_grade = students[i]->grade();
            streamsize prec = cout.precision();
            cout << setprecision(3) << final_grade << setprecision(prec) << endl;
        }
        catch (domain_error e)
        {
            cout << e.what() << endl;
        }
        delete students[i];
    }
    return 0;
}

01.04.2016, 22:52. Показов 43080. Ответов 2


Студворк — интернет-сервис помощи студентам

Не суть важен текст программы, как то, что у меня не получается подключить функции.
Выдает ошибку:
С3861 «название функции»: идентификатор не найден

Подскажите, пожалуйста, что делать.
Вот что я нашел:
]identifier: идентификатор не найден
Компилятору не удалось разрешить ссылку на идентификатор даже при поиске с зависимостью от аргументов.
Чтобы устранить эту ошибку, проверьте написание и регистр объявления идентификатора. Убедитесь, что операторы разрешения области действия и директивы using пространства имен используются правильно. Если идентификатор объявляется в файле заголовка, убедитесь, что заголовок включен до ссылки на него. Кроме того, убедитесь, что идентификатор не исключен с помощью директив условной компиляции.

Но, честно говоря, не особо понял что надобно делать.
Может, я что-то не подключил?

А вообще, в начале всего этого просто выделяется память для динамического двумерного массива.

C++
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#include <iostream>
#include <conio.h>
#include <math.h>
using namespace std;
 
void main()
{
    setlocale(LC_ALL, "Russian");
    int n, p;
    double **a = NULL;
    double **b = NULL;
    double **c = NULL;
    double **a1 = NULL;
    double **b1 = NULL;
    cout << "Введите размерность массива (число n): ";
    cin >> n;
    NewMemory(a, n);
    NewMemory(b, n);
    NewMemory(c, n);
    NewMemory(a1, n);
    NewMemory(b1, n);
 
    do
        {
            system("cls");
            cout << "1. Создание матрицы a " << endl;
            cout << "2. Создание матрицы b " << endl;
            cout << "3. Нахождение m-нормы матрицы a" << endl;
            cout << "4. Умножение матрицы B на число (b1= b*am)" << endl;
            cout << "5. Вычитание матриц(a1=a-b1)" << endl;
            cout << "6. Обращение матрицы( с=a1^(-1)" << endl;
            cout << "7. Вывод всех матриц(a, a1, b, b1, c)" << endl;
            cout << "8. Конец работы" << endl << endl;
            cout << "Укажите пункт меню: ";
            cin >> p;
            switch (p) 
            {
            case 1: AarrayCreator(a, n);
                break;
            case 2:
                break;
            case 3:
                break;
            case 4:
                break;
            case 5:
                break;
            case 6:
                break;
            case 7:
                break;
            case 8:
                DeleteArray(a, n);
                DeleteArray(b, n);
                DeleteArray(c, n);
                DeleteArray(a1, n);
                DeleteArray(b1, n);
                return;
            }
            _getch();
        } while (true);
    system("Pause");
}
 
 
void NewMemory(double **&h, int n)
{
    h = new double* [n];
    for (int i = 0; i < 2; i++)
        h[i] = new double[n];
}
 
void DeleteArray(double **&h, int n)
{
    for (int i = 0; i < n; i++)
        delete[] h[i];
}
 
double AarrayCreator(double **h, int n) {
    for (int i = 0; i < n; i++)
        for (int j = 0; j < n; j++)
            h[i][j] = (sin(i + j))*sin(i + j);
}

P.S. я не знаю насколько правильный весь код. Сразу извиняюсь за корявость
P.S.S Ошибку он мне выдает на каждое объявление функции. Всех функций



0



I have a problem with my code. Unfortunately, when compiling I get these errors all the time. What can this be caused by and how to fix it?

error C3861: ‘print’: identifier not found

My code:

main.cpp

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

using namespace std;

int main()
{
    Pojazdy** poj;
    int size{ 0 }, index{ 0 };
    Petla(poj, size);

    print(poj, size);

    wyrejestruj(poj,size,0);
    print(poj, size);
    wyrejestruj(poj,size);

    return 0;
}

pojazdy.h

#ifndef pojazdy_h
#define pojazdy_h

#include <iostream>
#include <cstdlib>

using namespace std;

class Pojazdy
{
public:
    string typ;
    string marka;
    string model;
    string z_dod;
    int ilosc;
    int cena;

    void dodaj();
    void d_pojazd(Pojazdy**& pojazdy, int& size);
    void wyrejestruj(Pojazdy**& pojazdy, int& size, int index);
    void print(Pojazdy** pojazdy, int size);
    void Petla(Pojazdy**& p, int& size);

    //void wyswietl();
    int get_ilosc() { return ilosc; }
    string get_typ() { return typ; }
    string get_marka() { return marka; }
    string get_model() { return model; }
    int get_cena() { return cena; }
    void set_ilosc(int x);
};

#endif

pojazdy.cpp

#include "pojazdy.h"

#include <iostream>

using namespace std;

void Pojazdy::set_ilosc(int x) { ilosc = x; }

void Pojazdy::dodaj()
{
    cout << "DODAWANIE POJAZDU..." << endl;
    cout << "Podaj typ pojazdu:";
    cin >> typ;

    cout << "Podaj marke pojazdu: ";
    cin >> marka;

    cout << "Podaj model pojazdu: ";
    cin >> model;

    cout << "Dodaj cene pojazdu: ";
    cin >> cena;
}

void Petla(Pojazdy**& p, int& size) {
    char z_dod;// = 'N';
    do {
        d_pojazd(p, size); //odpowiada za dodawnie
        p[size - 1]->dodaj();
        cout << "Czy chcesz zakonczyc dodawanie? Jesli tak, wcisnij Y/N: ";
        cin >> z_dod;

    } while (z_dod == 'N' || z_dod == 'n');//while (p[size]->z_dod == "N" ||p[size]->z_dod == "n");
}

void print(Pojazdy** pojazdy, int size) {
    std::cout << "====================================" << std::endl;
    for (int i{ 0 }; i < size; i++)
        std::cout << "Typ: " << pojazdy[i]->get_typ() << " Marka: " << pojazdy[i]->get_marka() << " Model: " << pojazdy[i]->get_model() << " Cena: " << pojazdy[i]->get_model() << std::endl;
}

void wyrejestruj(Pojazdy**& pojazdy, int& size) {
    for (size_t i{ 0 }; i < size; i++)
        delete pojazdy[i];
    delete[] pojazdy;
    size = 0;
    pojazdy = NULL;
}

void wyrejestruj(Pojazdy**& pojazdy, int& size, int index) {
    if (index < size) {
        Pojazdy** temp = new Pojazdy * [size - 1];
        short int j{ -1 };
        for (size_t i{ 0 }; i < size; i++) {
            if (i != index) {
                j++;
                temp[j] = pojazdy[i];
            }
        }
        delete[] pojazdy;
        --size;
        pojazdy = temp;
    }
    else
        std::cout << "Pamiec zwolniona!" << std::endl;
}

void d_pojazd(Pojazdy**& pojazdy, int& size) {
    Pojazdy** temp = new Pojazdy * [size + 1];
    if (size == 0)
        temp[size] = new Pojazdy;
    else {
        for (int i{ 0 }; i < size; i++)
            temp[i] = pojazdy[i];
        delete[] pojazdy;

        temp[size] = new Pojazdy;
    }
    ++size;
    pojazdy = temp;
}

I used #ifndef, #define, #endif and #pragma once, but none of them work. I will be really grateful for every code, I am already tired of this second hour. And forgive the non-English variables and function names for them — it’s university code, so I didn’t feel the need.

  • Remove From My Forums
  • Question

  • My C++ code compiles fine with VS 2013 but when I have compiled with VS 2015 I get this error:

    C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\atlmfc\include\atlwinverapi.h(710): error C3861: 'LCMapStringEx': identifier not found
    

    I don’t use LCMapString anywhere in my code, so I don’t know where this come from? Can you help me in resolving this error?

    • Moved by

      Wednesday, January 11, 2017 7:21 AM

Answers

    • Marked as answer by
      smhaneef
      Wednesday, January 11, 2017 2:40 PM

Понравилась статья? Поделить с друзьями:

Интересное по теме:

  • Ошибка климат контроля пассат б5 444
  • Ошибка компас 3д ksys2 dll
  • Ошибка кода 4937
  • Ошибка компилятора cs0012
  • Ошибка компилятора c3867

  • Добавить комментарий

    ;-) :| :x :twisted: :smile: :shock: :sad: :roll: :razz: :oops: :o :mrgreen: :lol: :idea: :grin: :evil: :cry: :cool: :arrow: :???: :?: :!: