Numeric_limits class Problem

Hi guys! :wave:t4:

I have a problem with numeric_limits class. My VS Code recognise “numeric_limits” as undefined identifier instead of a class and size() is not working in my VS Code as well. How to solve this problem?

size() issue:

  • For std::numeric_limits, include <limits> header file.
  • For std::size, include one that fits.

what should I include for std::size ?
i didn’t understand your suggestion for size function :sweat_smile:

std::size has multiple implementations in different classes. It is a method (class-only function) and not a normal (common) function.

1 Like

Got it buddy, Thank you!

Here, check this answer:

My compiler version is C++17 and it is still not getting compiled after adding <iterator> headerfile as you suggested,buddy.

MyCode

#include<iostream>
#include<iterator>
using namespace std;

void printNumbers(int numbers[],int size);

int main(){
    int numbers[]= {10,20,30};
    printNumbers(numbers,size(numbers));

    return 0;
}

void printNumbers(int numbers[],int size){
    for(int i=0; i<size; i++)
        cout<< numbers[i] << endl;
}

Look at the terminal window, it still states that " ‘size’ was not declared in this scope
printNumbers(numbers,size(numbers));" after compiling my source code!

Try this:

1 Like