Anonymous
#include <queue> using namespace std; template <typename T> struct comp { bool operator()(T a, T b) { return a > b; } }; int main() { priority_queue<int, vector<int>, comp<int>> p; return 0; } How can I declare comp so that I can plug it into priority_queue's class Compare without the template argument? Like, priority_queue<int, vector<int>, greater<>> does not need greater<int> This probably falls under template specialization and I'm having trouble understanding it.
There is not much advanced template magic here. Infact it is pretty simple. Since C++14, std::greater is defined like this: template< class T = void > struct greater; You can do something similar by providing a default template parameter argument for your comp struct. std::greater uses void as its default type and then specializes greater for void by defining operator() as a template function. You could do something similar as well like I have shown below: template <typename T=void> struct comp { bool operator()(const T& a, const T& b) { return a > b; } }; template<> struct comp<void> { template<typename T, typename U> bool operator()(T&& a, U&& b) { return a>b; } }; Now you can do something like: priority_queue<int, vector<int>, comp<>> q;
Lengashe
anyone with microprocessor knowledge to help me this please
alice
How to solve 5 variable 5 liner questions using c++
Lengashe
1. Microcontrollers’ cannot be used instead of Microprocessors. Justify how Microcontroller cannot be used in place of microprocessor and using a microprocessor is not advised in place of a microcontroller. 2. Explain the difference between a JMP instruction and CALL instruction 3. How does the microprocessor differentiate between data and instruction? 4. How many interrupts does 8085 have, mention and explain them 5. Assume the content of memory locations 4001H is 51H and 2000H is 19H. Write instruction to subtract the contents of memory location 4001H from the memory location 2000H and place the result in memory location 4002H. 6. Write the Assembly language program to add the two Hex numbers. Both the numbers should be saved for future use. Save the sum in the accumulator. Numbers: A2H and 18H are stored in memory location 8080H and 8081 respectively 7. Write an assembly program that computes the 2’s compliment.
Hanz
I wonder which CS school allows you to seek help from internet
Hanz
IMO, docs is the maximum whomever can reach at that moment
klimi
some of my courses in uni are like that
Hanz
oh, alright. I think my opinion only applies to final exam
klimi
well... mostly the knowledge you have learnt is examined...
Pulkit
https://youtu.be/6QVjIZTDG8c
I haven't downloaded cmake Everything else I have Plus the issue only arises with few programs only hello world works fine
Arnold
@Abdullah00125 Idiot!
Arnold
Many scammers on telegram
klimi
what?
Kezias
Hello
Talula
Mostafa
hey is there any general way to serialize data structure in c?
Anonymous
Hey admin can i share daily hacking news in this group Like this ?
_
how can i get a string as input from a user in c?
_
Use gets
gimme an example
klimi
gimme an example
#include <stdio.h> int main(void) { char name[20]; printf("Hello. What's your name?\n"); //scanf("%s", &name); - deprecated fgets(name,20,stdin); printf("Hi there, %s", name); return 0; }
mito
Use gets
fgets()* https://stackoverflow.com/a/4309845
Anonymous
Someone to assist me with C program that will prompt the user to enter all even number between 0 to 30 and find there sum
Oky--
Someone to assist me with C program that will prompt the user to enter all even number between 0 to 30 and find there sum
#include<stdio.h> Int main() { Int n,sum=0; scanf("%d"',&n); for(int i=0 ;i<n;i++) { sum=sum+i; } printf("%d",sum); }
\Device\NUL
sure, you could do that i guess
fgets will contain newline if user entered it with newline, i'm lazy to check if the end of string is newline or not (in case the user send EOF signal).
Davy
Hey everyone!🙌🏻
Davy
I need to bypass something on my laptop, can someone help?
klimi
I need to bypass something on my laptop, can someone help?
What is it? I sure hope its not something skid would say
Davy
I forgot the bitlocker password, and I can’t access the laptop without it
klimi
klimi
You don't even have the data... So ... Its not really a bypass
Davy
I heard it’s possible
klimi
I heard it’s possible
How do you get data if you don't have the data? You need the key to decrypt the data
Davy
Well that’s the problem, I haven’t got the key
klimi
Well that’s the problem, I haven’t got the key
Yeah exactly, therefore you cannot access the data, there is no bypass
Davy
No hacking or something? Or like a way
klimi
No hacking or something? Or like a way
Um... You could bruteforce it... But as you know that would probably take ages
klimi
No hacking or something? Or like a way
"No hacking or something" that's a legendary quote
Davy
U mean ages literally or?
klimi
U mean ages literally or?
Depends on the password you have set
klimi
If it were me I would set something long so... Yes... Literally ages
olli
I forgot the bitlocker password, and I can’t access the laptop without it
apart from the password bitlocker sets a recovery key and asks you where you want to store it. It usually either makes you store it online, on an external drive or print it. If you have stored it online you could try to get your recovery key from your MS Account. https://support.microsoft.com/en-us/windows/finding-your-bitlocker-recovery-key-in-windows-6b71ad27-0b89-ea08-f143-056f5ab347d6
Davy
I was thinking about reinstalling the windows again
Jack ⁧3
Heavy violation of DRY concept
klimi
Yes you can
klimi
But you will lose your existing data
Davy
Ya not the first time :)
klimi
Ya not the first time :)
Then sure, you can do that
Davy
Thanks! And I was on slow mode, that’s why I repeated myself:)
Leovan
Who's know how to use #include directive in GLSL? Can't find any information
Pavel
Who's know how to use #include directive in GLSL? Can't find any information
Maybe this can help https://stackoverflow.com/questions/10754437/how-to-using-the-include-in-glsl-support-arb-shading-language-include
Anonymous
hello koi help karega ek ??
Anonymous
English please
okk i will try
Anonymous
#include <iostream> using namespace std; class A { int a, b; public: void setData1(int x, int y) { a = x; b = y; } void print(void) { cout << " the value of a is : " << a << endl; cout << " the value of b is : " << b << endl; } void setData2(void) { cout << " enter the value of a : "; cin >> a; cout << " enter the value of b : "; cin >> b; } }; int main() { A aa; aa.setData1(1, 2); aa.print(); aa.setData2(); aa.print(); return 0; }
Anonymous
this is a simple program to print two number .
Anonymous
but in setData1 I use the parameter and then set the value and in setData2 direct setting the value so any difference between both of function to setting the value ??
M. Wahyu
C/C++ programming language have group/channel/server on discord ?