Hello,
The following function gives me a warning: -
template <class V, class I, class S>
-
I Array<V, I, S>::MaxIndex() const
-
{ // Return the maximum index
-
-
return m_start+Size()-1;
-
}
-
And I get the following warning:
'return' : conversion from 'size_t' to 'int', possible loss of data
How can I get rid of this warning?
6 9418
Hello,
The following function gives me a warning: -
template <class V, class I, class S>
-
I Array<V, I, S>::MaxIndex() const
-
{ // Return the maximum index
-
-
return m_start+Size()-1;
-
}
-
And I get the following warning:
'return' : conversion from 'size_t' to 'int', possible loss of data
How can I get rid of this warning?
Well, you could use a cast if you are sure that Size() is never going to be > than INT_MAX:
return m_start+(int)Size()-1;
or so it really sticks out if you need to change it later
return m_start+static_cast<int>(Size())-1;
Thanks. Do you know, how can I see my output in visual c++ express. Even though I have no errors or warnings after the build. I don't see the output of the program under the output tab.
Stop casting. The compiler is telling you there may be a problem.
The problem is:
size_t in 64 bit Unix is 64 bits
size_t in 64 bit Windows is 32 bits.
Visual Studio is concerned that since you are using a Unix data type, you may be porting code from Unix to WIndows and if that happens to be a port deom 64 but Unix to 64 bt Windows, you will lose data.
Go to your project properties and select Configuration Properties. Then select C/C++. Then select General. Here set the property "Detect 64-bit Portability Issues" to NO and your warning will disappear.
Do not cast in C++ unless there is a harpoon in your side.
OK, thanks. Do you know where I can see the output of a program in Visual c++ Express. In the output window it says:
[HTML]1>Linking...
1>LINK : C:\Users\admin\Documents\Visual Studio 2005\Projects\vec\Debug\vec.exe not found or not built by the last incremental link; performing full link
1>Embedding manifest...
1>Build log was saved at "file://c:\Users\admin\Documents\Visual Studio 2005\Projects\vec\vec\Debug\BuildLog.htm"
1>vec - 0 error(s), 0 warning(s)[/HTML]
Is there something wrong? Or output is in somewhere else?
Do you mean output when the program is executed or output from the build??
Output from execution is in an execution window that's made to look like the Command Interpreter. Select "Start without debugging" from the Debug menu.
Output from the build is what you are showing in your post.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Abhijit Bhadra |
last post by:
Hi ,
I am using gcc version 3.3.2. While compiling this code
struct sockaddr_in *CBaseSocket::GetSocketName()
{
socklen_t iLen;
cCriticalSocket.Lock();
//...
|
by: Kamil Grymuza |
last post by:
Hello
How to convert int and float values to strings? I mean std::string not
char*.
Thanks
Kamil Grymuza
|
by: Dennis |
last post by:
I get the following results:
Cint(&HC5798A2F) returns -981890513 as it should and
Clng("&HFFFFFFFFC5798A2F") returns -981890513 as it should.
However when using a string
...
|
by: AmmarN |
last post by:
HI All;
I am having a problem changing the value of an enum. I have a struct as shown below:
typedef struct
{
union
{ long lV; volatile char c; } u1;
|
by: fazulu deen |
last post by:
Hi all,
For the following code :
file_ptr = fopen("pass_fail.txt", "a"); // error line 393
fdisplay(file_ptr, "Test Passed");
fclose(file_ptr);
|
by: Nozdormu |
last post by:
Hi guys, I have a quick question. The language I'm using is C.
The question I'm tackling:
Write a program that
(1) defines a 1D array with ten int elements, and
(2) sets the values of the...
|
by: Markus Dehmann |
last post by:
I have two integers i1 and i2, the second of which is guaranteed to be
between 0 and 99, and I encode them into one double:
double encoded = (double)i1 + (double)i2 / (double)100;
So, for...
|
by: kenneth6 |
last post by:
int a=10;
int b=3;
float c;
c=a/b;
cout << c << endl;
if, in my program, the int type for a and b is a must (according to the return), performing operation on a & b results in float type...
|
by: Tex08 |
last post by:
I have hit a roadblock on a class project. Trying to implement the composite pattern with separate classes to represent a boolean expression. My literal class will not compile (g++, required...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome former...
|
by: ryjfgjl |
last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
| | |