1

I am wrote a simple c++ program and using range for loop to access vector contents.

#include<iostream>
#include<vector>

int main()
{
    std::vector<double> v1 = {1.1, 2.2, 3.3, 4.4, 5.5,6.6};

    for(int i:v1)
    {
        std::cout<<i<<"\t";
    }
    std::cout<<"\n";

    return 0;
}

I am compiling using: g++ -Wall prog3.cpp -o prog3 And getting output as: 1 2 3 4 5 6

I did not get double to int conversion warning. How can I get this warning and avoid narrowing down type?

vcx34178
  • 961
  • 1
  • 8
  • 15

0 Answers0