mercredi 6 juillet 2016

char to double conversion [duplicate]

This question already has an answer here:

I'm using visual studio 15, and it generates an error when compiling code:

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

using namespace std;

int main()
{
    char a = 1;
    double i{ a };
    cout << i;
    return 0;
}

The error is:

error C2397: conversion from 'char' to 'double' requires a narrowing conversion

I can not understand why, because in this conversion I think there is no narrowing.

Aucun commentaire:

Enregistrer un commentaire