Would there be anyway for the compiler, or the language, to provide a unique ID during compilation?
I've been using UUID generators, but I've always found the approach of copy pasting from a program to code to be kind of... limiting. If I want a random number, can't the compiler guarantee this for me?
It already does the same thing for anonymous namespaces, so...
As you see, I have taken input from the user just after calculating the whole palindromes. So cant we calculate this at compile time? because runtime of this program is extremely slow.
Another qs. I first tried to use array but It didnt allow 2*10^9 sized array. so what should I do whenever I need that size of array?
My question is this: Is it possible to determine where functions are stored at compile time, so that at run time you can pass the memory address as a pointer to the interrupt handler so that it can directly call the function at memory location 'X'?
The newest project I'm working on would require to either somehow capture these addresses or to find a work-around so that instead of passing the pointer to the interrupt handler, the software would then need to be able to be non-interruptable.
Consider: Code: template<unsigned int N> class Test { private:
[Code]....
I just cannot understand why (clearly, we are calling <0, 0>, not <0, 8>). If I replace "N" with 8, it works as expected (at least for the beginning of the loop). I only tested on MSVC.
I am working on a project, where I have to be able to exclude some code fast and dynamicly at compiletime.
I got a scheduler running and actually I just want to remove some of the tasks from it - but at compile time so that the code wont take up space in my microcontroller.
I know that I can use macros like #ifdef #endif etc. But I think that method makes the code unreadable and complicated.
How to archive such functionality a more elegant way?
So I made a library for a whole bunch of functions and when i compile it, it says"Unresolved external symbol_(Name of function here) referenced in function main.
How do I set the size of a member array via the class constructor if I know the size at compile time. I can do this with templates, see below, but this leads to code bloats, I think.
So one class declaration but objects with different array sizes.
Can't use constexpr. Can't use STL. Can't use new.
#include <iostream> using namespace std; template<int T> class MyArray { private: int array[T]; public: int getSize()
I want to generalize my productFunction below to a template family of functions where the template merely changes the * to + or whatever else operator I wish to use.
How can I turn a template parameter into various operators? (apart from using switch statements that will reduce the performance and make the code really ugly) What kind of metatemplating method converts a compile-time constant to an operator?
Code: typedef struct token { int tokenType; // what token is that int tokenCode; // the code of a function if applicable char *tokenString; // Source token double tokenValue; // if token is a number
[Code] .....
I got several warnings and erros, is it possible to declare a table like that ? What's the correct way to declare it ?
I have an issue with a switch case in my program. I execute it and it does fine all the way up to where it says, "Answer (1, 2, or 3): ". When I enter 1, 2, or 3, it gives me' "Not an input choice!" from the default of the switch case.
NOTE: I use Code::Blocks on Windows XP.
Here is the code:
Code:
#include <stdio.h> #include <string.h> int main() {
I have an assignment for uni which requires the program to ask the user to input a number in for a variable to use in later equations. The assignment specifies that if the number that is input into the program is not an interger that it needs to be rounded UP to the nearest interger. e.g. 2.5 = 3, 5.00001 = 6 etc. i have identified this variable using "int" which i know makes it an interger however it also always rounds the number DOWN to the nearest interger. I was just wondering what the best way to approach this problem was. The only idea i have is to put + 0.99999 at the end of this variable when it is worked out so that if it is not a whole number it will be raised above the next interger and then rounded down however this will not work if there is too many decimal places.
I am working on a couple C++ projectsfor my class. On one of my projects I get this error "identifier not found" for maximumValue. here is the code that I have done. I have got almost all the code from my text book..
// Three numbers.cpp : Defines the entry point for the console application.//
#include "stdafx.h" #include <iostream> using namespace std; int main() { // demonstrate maximum int value int int1, int2, int3;
Program is not finished as I can't get passed read_data
Error: "error C2065: 'fin' : undeclared identifier error C2228: left of '.open' must have class/struct/union type is ''unknown-type''
#include "stdafx.h" #include <iostream> // for streams #include <iomanip> // for setw() #include <fstream> // for files #include <cstdlib> // for exit using namespace std; void read_data(int A[], int size)
I need to keep a data structure, which has an id, an object pointer and a position. this id is used to randomize things, the object and the position is attached to this id. So which way is better?
Code: struct data { int id; ObjectBase* obj; Vector3 position; }; vector<data> vecData;
This is a round robin execution. with gantt chart. arrival time and burst time. I think there is an error in my formula to get the right answer,i cant resolve it but my program is running. What is the code or the right formula??
#include<stdio.h> int main(){ int i,j=0,n,time,remain,flag=0,ts; int sum_wait=0,sum_turnaround=0,at[10],bt[10],rt[10]; int ganttP[50],ganttStartTime[50]; printf("Enter no of Processes : "); scanf("%d",&n); remain=n;
I'm writing a program to read in a Master.txt file and then update it through a Transaction.txt file that contains various transaction types [Adds (A), Deletes (D), and Edits (E1-E4)]. The records in both files are in ascending order based on Item#. Ultimately, the original Master.txt and updated Master file (Master2.txt) will be merged to reflect all valid transactions, and an errorLog.txt file will be created to indicate all invalid transactions. I feel I have all of the code written correctly, but I am still getting errors on my operands and identifiers.
I'm trying to perform a simple input operation, and check to make sure that whatever the user input is a valid input (is within data type bounds, is correct data type...). But when I get to ignoring the input, I keep getting an error.
unsigned short num; while (true) { std::cin >> num; if (std::cin.fail()) { num = 1;
I have some code does not compile. I think it's missing an included library, but not sure.
In the int main() block of code, the following three items give errors:
1. Mtrx (the one following "new") - Error: expected a type specifier 2. result - Error: expected a ";" 3. &result - identifier "result" is undefined
Below is the code with the head to show you what has been included:
HTML Code: #include <iostream> #include <iomanip> using namespace std; #include <limits.h> // create the structure of the matrix struct Mtrx { int numRows; int numCols; float array[101][101];