|
Thanks Rechard for this clear explanation.
|
|
|
|
|
Very interesting!
I've never seen this code.
If I wanna plus all numbers between 1 to 1000 with out loops, how can I do it like above method?
Thank you for you advice!
|
|
|
|
|
Use a static variable and just add the value of j to it each time.
|
|
|
|
|
Thank you! 
|
|
|
|
|
I have an application developed in non-CLR C++ (unmanaged) in VS2003 (or earlier) but working with VS2005 after some converting. Note that I didn’t do that converting.
My employer decided to update the code to CLR VS2010 for easier maintenance. I am a C# programmer and haven’t done C++ for a while and not within VS so I’m not the most skilled in this task.
I’ve set it to CLR and corrected the errors and most of the warnings, but I’m having a problem with some image resources in the Form1.resX file (took me a while to even figure out that the resources were IN that .resx file I can see them in there and the Form [Design] editor can see the resource and paints the image as a background for its tab:
this->tabPage1->BackgroundImage = (safe_cast<system::drawing::image ^="">(resources->GetObject("tabPage1.BackgroundImage")));
The resX file is version 1.3 of the schema or so it says rather than the 2.0 that a newly created windows forms application has but seems OK otherwise.
<root>
modified 21-May-14 16:11pm.
|
|
|
|
|
|
Well it's not Managed C++/CLI that is for sure.
The makefile mentions gcc and you can find instructions on how to use gcc and a makefile here[^]
|
|
|
|
|
It looks very much like UNIX: all those shell scripts are a dead giveaway. So load it into your UNIX/Linux system, type 'make' and away you go.
|
|
|
|
|
(just realized this question is really old! oh well - might help someone)
I recently ran into a similar issue.
This worked for me:
- In Visual Studio create a C++ Win32 console application
- Add the .C files to the solution (add...existing item)
- Compile - default output is .exe
(The makefile seems to just compile the code - I think the .sh scripts might cleanup after the compiler. But, yeah, the makefile is designed to run in a linux/unix)
Erik Westermann
|
|
|
|
|
how to conver any base like binary to any base like hexadecimal and octal or others bases give me code
|
|
|
|
|
|
code to convert any base like binary to any base
|
|
|
|
|
Is this a question or a statement?
|
|
|
|
|
Hi Iam trying to convert my Digit To Words class from c# to VC++... And the following line I am facing trouble
String^ strNum;
String^ strNumDec;
String^ StrWord;
strNum = Convert::ToString(Num);
blah..blah...blah...
StrWord = ((double.Parse(strNum) == 1) ? " Rupee " : " Rupees ") + NumToWord((decimal)(double.Parse(strNum))) + ((double.Parse(strNumDec) > 0) ? (" and Paise" + cWord3((decimal)(double.Parse(strNumDec)))) : "");
Thanks for the helps
|
|
|
|
|
Paramu1973 wrote: trouble
And that trouble would be what exactly?
Paramu1973 wrote: blah..blah...blah...
is not valid C++ or C# code.
|
|
|
|
|
What type is Num and why are you converting it to a string just so that you can parse it into a double? Please provide more details of exactly what problem you are trying to solve.
|
|
|
|
|
Thanks Richard...Still I remember your powerful helps.....Num is Decimal and I found the solution...
Thanks Again
|
|
|
|
|
Is it really C# code? 
|
|
|
|
|
Create an STL vector of 10 integers and store initial values (0 to 9 is fine).
Use the std::random_shuffle algorithm to shuffle the list.
Print the list. (try to do this one with an std iterator)
Use the std::sort algorithm to sort the list.
Print the list again. (you can use for each instead of an iterator)
See if you can locate the documentation for random_shuffle and sort either in VS help or with Google. Once you leave this class, you will need to be able to find information like this on your own.
Checklist
1. Did NOT create a folder for the solution
2. Project/solution named correctly
3. Correct comments at top
4. Consistent indentation
5. Good variable names
6. Overall neat organization
7. Comments in code explain what's being done
8. Correct division of code into .h and .cpp files
9. Use of #pragma once in .h files (or, #ifndef)
10. #include "stdafx.h" in cpp files (or, suppress pch)
|
|
|
|
|
|
What does this mean? If you expect me to do your work for you then you are going to be disappointed.
|
|
|
|
|
hi this code is a part of keecak function.
i do not undrastand what is "C[index(x-xOff)];" plz help me;
template<class Lane>
void KeccakF::inverseTheta(vector<Lane>& A) const
{
vector<Lane> C(5);
for(unsigned int x=0; x<5; x++) {
C[x] = A[index(x,0)];
for(unsigned int y=1; y<5; y++){
C[x] ^= A[index(x,y)];
}
}
const LaneValue inversePositions64[5] = {
0xDE26BC4D789AF134ULL,
0x09AF135E26BC4D78ULL,
0xEBC4D789AF135E26ULL,
0x7135E26BC4D789AFULL,
0xCD789AF135E26BC4ULL };
vector<LaneValue> inversePositions(5, 0);
for(unsigned int z=0; z<64; z+=laneSize)
for(unsigned int x=0; x<5; x++)
inversePositions[x] ^= inversePositions64[x] >> z;
for(unsigned int z=0; z<laneSize; z++) {
for(unsigned int xOff=0; xOff<5; xOff++)
for(int x=0; x<5; x++)
for(unsigned int y=0; y<5; y++)
if ((inversePositions[xOff] & 1) != 0)
A[index(x, y)] ^= C[index(x-xOff)];
for(unsigned int xOff=0; xOff<5; xOff++) {
ROL(C[xOff], 1);
inversePositions[xOff] >>= 1;
}
}
}
|
|
|
|
|
index() is a function that takes two values and returns another value. You need to find the documentation for it to know what all the values represent.
|
|
|
|
|
mostafaghanei wrote: this code is a part of keecak function
Ahh, Keecak eh? Yes, that's very well known. I am sure someone can tell you what it does.
"The whole idea that carbon dioxide is the main cause of the recent global warming is based on a guess that was proved false by empirical evidence during the 1990s." climate-models-go-cold
|
|
|
|
|
THE QUESTION IS AS FOLLOWS:
Create a template class called Array that implements an array and works with any type (int, double, etc.). The constructor should take a size for the array and use new to allocate memory (don't forget to delete in the destructor). Overload operator[] to access the elements of the array. If an attempt is made to access an element outside the array bounds (either above OR below), throw an exception. In the main program, first create an Array<int> object, add a few values, and demonstrate that operator[] throws an exception if an attempt is made to access an out-of-bounds elements. Catch the exception and print an appropriate message. Then do the same thing with an Array<std::string>.
Hint: you will need both of these overloads:
T& operator[](int i)
const T& operator[](int i) const
I DID THE PROGRAM IN MAIN AS FOLLOWS AND IT DOES WELL IN THE MAIN BUT ITS GIVING ME HARD TIME DIVIDING IT INTO DIFFERENT FILES.
#include "stdafx.h"
#include <iostream>
using namespace std;
#include <exception>
#include "Array.h"
template <typename T>
class Array
{
int size; T*array;
public:
Array(int s)
{
size=s;
array=new T [size];
}
~Array()
{
delete [] array;
}
const T &operator[](int i) const
{
if(i < 0)
throw exception("Index out of bounds LOWER");
else if(i>=size)
throw exception("Index out of Bounds OVER");
else
return array[i];
}
};
int _tmain(int argc, _TCHAR* argv[])
{
Array <int> num(12);
try
{
int i=num[-1];
}
catch (std :: exception & ex)
{
cout<<ex.what()<< endl;
}
Array <string> num1(12);
try
{
string j=num1[14];
}
catch (std :: exception & ex)
{
cout<<ex.what()<< endl;
}
cin.get();
cin.get();
return 0;
}
THEN I DIVIDED THE PROGRAM INTO DIFFERENT FILES AS FOLLOWS:
IN ARRAY.H
#pragma once
template <typename T>
class Array
{
public:
Array(int s);
~Array();
const T &operator[](int i)const;
private:
int size; T*array;
};
IN ARRAY.CPP
#include "stdafx.h"
#include <iostream>
using namespace std;
#include <exception>
#include "Array.h"
template <typename T>
Array<T>::Array(int s)
{
size=s;
array=new T [size];
}
template <typename T>
Array<T>::~Array()
{
delete [] array;
}
template <typename T>
const T & Array<T>::operator[](int i) const
{
if(i < 0)
throw exception("Index out of bounds LOWER");
else if(i>=size)
throw exception("Index out of Bounds OVER");
else
return array[i];
}
IN MAIN
#include "stdafx.h"
#include <iostream>
using namespace std;
#include <exception>
#include "Array.h"
int _tmain(int argc, _TCHAR* argv[])
{
Array <int> num(12);
try
{
int i=num[-1];
}
catch (std :: exception & ex)
{
cout<<ex.what()<< endl;
}
Array <string> num1(12);
try
{
string j=num1[14];
}
catch (std :: exception & ex)
{
cout<<ex.what()<< endl;
}
cin.get();
cin.get();
return 0;
}
PLEASE REPLY SOON.
|
|
|
|