error problems

This is a discussion on error problems within the C++ Programming forums, part of the General Programming Boards category; I am getting an undeclared identifier error when everything is declared correctly: source.cpp Code: const int bigger = 150000; int ...

  1. #1
    Registered User
    Join Date
    May 2004
    Posts
    11

    error problems

    I am getting an undeclared identifier error when everything is declared correctly:

    source.cpp
    Code:
    const int bigger = 150000;
    int bubbleArray[bigger];
    BubbleSort(bubbleArray, size);
    header.h
    Code:
    #ifndef H_SORTS
    #define H_SORTS
    
    #include <iostream>
    
    using namespace std;
    
    class sorting
    {
    public:
    	void BubbleSort(int array[], int length);
    Can anyone help?

  2. #2
    Registered User jlou's Avatar
    Join Date
    Jul 2003
    Posts
    1,088
    Post more code, post the exact error, show which line number the error refers to.

    Since BubbleSort is a member of the sorting class, you should probably be calling it from inside another member function, or you should call it from an instance of sorting.

  3. #3
    C Programmer Stack Overflow's Avatar
    Join Date
    Apr 2004
    Posts
    477
    Hello,

    Are you calling on your function from within your structure?

    You may not be calling on your structure's members. For example, sorting.BubbleSort instead of BubbleSort.

    Edit: jlou has a valid point, also.


    - Stack Overflow
    Segmentation Fault: I am an error in which a running program attempts to access memory not allocated to it and core dumps with a segmentation violation error. This is often caused by improper usage of pointers, attempts to access a non-existent or read-only physical memory address, re-use of memory if freed within the same scope, de-referencing a null pointer, or (in C) inadvertently using a non-pointer variable as a pointer.

  4. #4
    Registered User
    Join Date
    May 2004
    Posts
    11
    fixed it

    thanks your input helped

Popular pages Recent additions subscribe to a feed

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21