|
If symbol is declared in the global namespace, it's still visible from other namespaces. If it's also declared in a named namespace, that's the declaration that would be picked up within that namespace unless qualified as ::symbol .
You're right that a forward declaration isn't required if you define the class--in the same file. There are times when an interface (.h) forward-declares a class that it uses in name only, and which is private (that is, implemented in its .cpp). This is done when using the PIMPL idiom[^].
|
|
|
|
|
Hi I have below code written while contesting on a platform, though I find working with code but it fails with different test cases especially when Input value is 1 and no string is provided. Can anyone please help to resolve this issue ?
#include <bits/stdc++.h>
using namespace std;
string reSize(string s)
{
if(s.length() > 0)
{
std::string res;
int count =1;
for(int i =0;i<(s.length() - 1);i++)
{
if(s[i] == s[i+1])
{
count++;
}
else
{
res += s[i];
if(count > 1)
{
res += std::to_string(count);
}
count = 1;
}
}
res += s[s.length() - 1];
if(count > 1)
{
res += std::to_string(count);
}
return res;
}
else if(s.empty())
{
return "";
}
}
int main() {
int t;
cin>>t;
while(t--)
{
string s;
cin>>s;
cout<<reSize(s)<<endl;
}
return 0;
}
modified 2-Apr-24 6:37am.
|
|
|
|
|
What you need to do is put a breakpoint in your code, and step through it a line at a time. When you are executing a line, think about what you expect the outcome of that operation to be and compare what you think should be happening with what actually happens. Generally, this will lead you to work out what the problem actually is. There's a name for this type of approach, it's called debugging, and it's one of the most valuable skills you will ever learn.
|
|
|
|
|
priyanka mp wrote: Can anyone please help to resolve this issue ? You have not actually expalined what the issues is. What is the code supposed to do, what inputs are you using, what results do you get, and why are they not correct?
|
|
|
|
|
what is this supposed to do ?
what is the input and what is the output ? (what are the test cases ? )
CI/CD = Continuous Impediment/Continuous Despair
|
|
|
|
|
You know, you cannot get an empty string using cin (see, for instance, Get empty input - C++ Forum[^]).
"In testa che avete, Signor di Ceprano?"
-- Rigoletto
|
|
|
|
|
Maybe its a contest. Guess the point and win the prize.
I do note that there are two possible inputs. So if '1' was put in for the first one, then I expect it works.
If put in for the second then I suspect '2', ..., '9' would also fail.
|
|
|
|
|
Se desea realizar una aplicación para llevar el control de las producciones que tiene una brigada de estudiantes en una empresa de cultivos varios en el mes de noviembre, la tarea es la recogida de tomates.
Es de interés para la empresa conocer.
a-Cuantas cajas de tomates se recogieron al analizar el mes.
b-En cuantos días la brigada cumplió la norma de producción. Tener en cuenta que la norma de producción es de 100 cajas.
c-La cantidad máxima de cajas recogidas.
d-La cantidad mínima de cajas recogidas.
e-El promedio de cajas recogidas en el mes.
f-Saber en cuantos días supero el promedio de cajas recogidas.
Haga uso del subprograma
PromedioCajas(), del inciso e.
Recuerde desarrollar un programa principal en el que se controle las llamadas a diferentes subprogramas que den solución a las necesidades existentes. Defina un menú, para que el usuario seleccione la opción que desee.
Translation:
We want to make an application to keep track of the productions of a brigade of students in a company of various crops in the month of November, the task is the collection of tomatoes.
It is in the company's interest to know.
a-How many boxes of tomatoes were collected when analyzing the month.
b-In how many days did the brigade comply with the production standard? Please note that the production standard is 100 boxes.
c-The maximum number of boxes collected.
d-The minimum number of boxes collected.
e-The average number of boxes collected in the month.
f-Know how many days I exceed the average number of boxes collected.
Make use of the applet
AverageBoxes(), of subsection e.
Remember to develop a main program in which you control the calls to different subprograms that provide solutions to existing needs. Define a menu, so that the user selects the option they want.
|
|
|
|
|
Do your own schoolwork.
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
In C++ you have ints, variables for floating point numbers, bools. Does Assembly have the same variable differentiation? Can you move any type of variable into a register?
|
|
|
|
|
yes and no.
There's no types in assembly.
You just move data to a register; the data can be anything (int, float, address to a string, ...)
CI/CD = Continuous Impediment/Continuous Despair
|
|
|
|
|
Not entirely true: floating point registers are still separate AFAIK. The rest are all the same.
Mircea
|
|
|
|
|
What about db, dw, dd, dq ... ?
|
|
|
|
|
Assembler does have (sort of) data types, in the way that you declare variables. But at the instruction level it is up to the programmer to ensure that the items are handled correctly. Take a look at NASM - The Netwide Assembler[^] for specific details.
|
|
|
|
|
Richard MacCutchan wrote: it is up to the programmer to ensure that the items are handled correctly Truth!
"the debugger doesn't tell me anything because this code compiles just fine" - random QA comment
"Facebook is where you tell lies to your friends. Twitter is where you tell the truth to strangers." - chriselst
"I don't drink any more... then again, I don't drink any less." - Mike Mullikins uncle
|
|
|
|
|
Richard thanks for your reference.
|
|
|
|
|
You are welcome. And NASM is a good introduction to Assembler, and machine code.
|
|
|
|
|
Thanks for your feedback guys
|
|
|
|
|
Hi,
as learning process, i need some code (or simple sample project) that shows how to post?send message from a library (dll) to application (dialog or console). If a thread in dll sends message to app, how is the best to approach that?. Using GetMessage?.
|
|
|
|
|
Keep in mind of course that a library doesn't do anything. Applications do stuff and use libraries.
So you want two applications.
You can start with researching (google) examples of Rest (http.)
|
|
|
|
|
Yes.
I am trying to experiment another feature that may become handy.
|
|
|
|
|
|
same message id is created in dll and in application?.
in application there is a routine that polls the messages. correct?.
|
|
|
|
|
Yes, you can create a message inside a DLL and send it to an application. But that still needs a controlling application to drive the DLL; so why would you do it that way? .A Windows (as opposed to a Console) application, must contain a message pump which pulls messages from its queue and processes them.
|
|
|
|
|
in case DLL need to inform application of something changed.
callback is better for this case?.
|
|
|
|